简体   繁体   中英

Some audio files are not playing using AVPlayer swift 4

I have 3 remote mp3 files to stream using AVPlayer

File 1 - Meta Data (Worked smoothly)

File 2 - Meta Data (Still showing as loading, not working ios but worked in android)

File 3 - Meta Data (This file is atleast playing something but no playback controls activated like seek, rewind, forward, backward, duration)

Find meta result here https://drive.google.com/drive/u/0/folders/1mvHGa6iPJba_Bv6NiYzTpwgHTRGHHd7J

This is the code i have implemeted

let destinationString = "https://example.com/audio.mp3"
let fileUrl = URL(fileURLWithPath: destinationString)
player = AVPlayer(url:fileUrl)
let vc = AVPlayerViewController()
vc.showsPlaybackControls = true
vc.player = player
self.view.addSubview(vc.view)
self.addChildViewController(vc)
player.play()

Searched a lot for supported file types and content types but doesn't get any relevant result even from apple documentation , Have anybody encountered this issue before ?

Totally helpless. Please help me.

Thanks in advance.

Try using string init for URL

let fileUrl = URL(string: destinationString)!

Something to start with. If this does not work try playing those files on your iPhone's safari. If it works then there is something wrong within the app else it could be a server issue.

At least this will help you debug the issue

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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