简体   繁体   English

在ios swift中使用AVPlayer播放mpga格式文件

[英]Playing mpga format files with AVPlayer in ios swift

I tried to run a remote mpga format audio file with AVPlayer in ios and doesn't play.我试图在ios中使用AVPlayer运行远程mpga格式的音频文件并且没有播放。 Below code works fine for remote mp3 files.下面的代码适用于远程 mp3 文件。 Can i change the MIME type for the file loaded or are there any options to play the mpga file in ios.我可以更改加载文件的 MIME 类型吗,或者是否有任何选项可以在 ios.js 中播放 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()

console shows控制台显示

nw_endpoint_flow_copy_multipath_subflow_counts Called on non-Multipath connection
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() 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM