无法播放流音频

时间:2018-11-30 19:01:58

标签: ios swift avfoundation

我想在iOS应用上播放流音频。我使用以下代码播放音频:

let url = URL(string: "http://online.radiorecord.ru:8102/chil_320.m3u")!
let asset = AVAsset(url: url)
let playerItem = AVPlayerItem(asset: asset)
let player = AVPlayer.init(playerItem: playerItem)
player.play()

当我在模拟器上运行应用程序时,出现此错误:

2018-11-30 21:57:26.097577+0300 radio[7417:21800733]
[AudioHAL_Client]    
AudioHardware.cpp:1210:AudioObjectRemovePropertyListener:  
AudioObjectRemovePropertyListener: no object with given ID 0

如何解决此问题?

1 个答案:

答案 0 :(得分:-3)

var player: AVPlayer?
let url = URL(string: "http://online.radiorecord.ru:8102/chil_320.m3u")!
player = AVPlayer(url: url)

player?.play()