gpt4 book ai didi

iOS-Swift-AVPlayer : Error playing with url containing khmer unicode

转载 作者:行者123 更新时间:2023-11-30 11:17:22 25 4
gpt4 key购买 nike

我刚刚用 AVPlayer 构建了一个自定义视频播放器,我发现我只能播放包含英文字符的 url 的视频(例如: http://app.ournsarath.com/uploads/videos/mp4s/09_03_2018_business.mp4 )。每当我传递包含高棉语 unicode 的网址(例如:http://app.ournsarath.com/uploads/sound/mp3s/01.06.2018Helpingothersចង់ជួយគ េ.mp4)时,播放器根本不播放。我是 iOS 开发新手。任何建议或指导将不胜感激。谢谢!

最佳答案

我找到了一个解决方案,在将 url 字符串传递到 AVPlayer 之前对其进行编码。

    func setupPlayer(link: String){
let encodedString = link.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
if let url = URL(string: encodedString!) {
player = AVPlayer(url: url)
let playerLayer = AVPlayerLayer(player: player)
self.layer.addSublayer(playerLayer)
playerLayer.frame = self.frame
player?.play()
}

关于iOS-Swift-AVPlayer : Error playing with url containing khmer unicode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51624799/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com