在iOS Swift中使用AVPlayer播放mpga格式文件

问题描述 投票:0回答:1

我试图在iOS中使用AVPlayer运行远程mpga格式的音频文件,但无法播放。下面的代码适用于远程mp3文件。我可以更改加载文件的MIME类型,还是可以在ios中播放mpga文件?

   let audioUrl = "https://example-files.online-convert.com/audio/mpga/example.mpga"   
   let url = URL(string: audioUrl)
   let player: AVPlayer = AVPlayer(url: url!)

   player.play()

控制台显示

nw_endpoint_flow_copy_multipath_subflow_counts Called on non-Multipath connection
ios swift avplayer avaudioplayer
1个回答
0
投票
let audioUrl = "https://example-files.online-convert.com/audio/mpga/example.mpga"
if let url = URL(string: audioUrl){   
   let playerItem = AVPlayerItem(url: url)
   let player: AVPlayer(playerItem: playerItem)
   player.play() 
}
© www.soinside.com 2019 - 2024. All rights reserved.