我正在開發一個iOS的廣播應用程序,需要能夠使用支持挪威字符「ÆØÅ」的編碼從音頻流中解析元數據。timedMetaData值有錯誤的編碼
在AVPlayerItem上使用timedMetaData這三個字符顯示爲「Ã」。
有誰知道如何更改timedMetaData項目的值(不是stringValue)上的編碼?或者,也許如何獲得原始價值?
代碼例如:
private var url = ""
private var player: AVPlayer!
private var playerItem: AVPlayerItem!
playerItem = AVPlayerItem(URL: NSURL(string: url)!)
player = AVPlayer(playerItem: playerItem)
playerItem.addObserver(self, forKeyPath: "timedMetadata", options: NSKeyValueObservingOptions.New, context: nil)
override func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer<Void>) {
guard keyPath == "timedMetadata" else { return }
for item in playerItem.timedMetadata! {
if item.commonKey == "title" {
let value = item.value
print(value)
//metadata = item.stringValue!
} else {
print(item.key)
}
}
}
您是否找到答案? –