我在iOS swift app中播放音频。
主要问题是avplayer必须加载所有文件才能开始播放
使用playImmediatelyAtRate不起作用,因为在文件完全下载之前,playbackBufferEmpty始终为true,这可能是长音频文件的问题。
有什么想法吗?
答案 0 :(得分:0)
不是真正与AVPlayer相关的答案,但您可以使用VLCKit来处理流。
以下是Swift中的基本示例:
let mediaPlayer = VLCMediaPlayer()
// replace streamURL by the url of the stream
mediaPlayer.media = VLCMedia(url: streamURL)
// outputView is the view where you want to display the stream
mediaPlayer.drawable = outputView
mediaPlayer.play()
如果您对VLCKit有任何疑问,请随时ping我!
答案 1 :(得分:0)
对于iOS> 10,我设置了:
avplayer.automaticallyWaitsToMinimizeStalling = false;
这似乎为我解决了。这可能会带来其他后果,但我还没有实现这些目标。