2
votes

I know this question was ask lot time but not get proper solution,

i have one m3u8 file which is not working in AVPlayer but if i use other m3u8 file which was already on internet that is working fine with AVPlayer ,here is my code

func playVideo() {
    let videoURL = URL(string: "https://architectsummit.s3.us-east-2.amazonaws.com/hls/playlist-with-vtt.m3u8")
    let player = AVPlayer(url: videoURL!)
    var playerViewController = AVPlayerViewController()
    playerViewController.player = player
    DispatchQueue.main.async {
        self.present(playerViewController, animated: true) {
            playerViewController.player!.play()
        }
    }
}      

in above code i used m3u8 file which provided by our developer , but if i use this url 'https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8' in above code video is playing what is issue anyone could help me.

1

1 Answers

3
votes

I oppened the .m3u8 link in browser and the manifest that is being downloaded is wrong. The manifest response is

#EXTM3U
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="English",DEFAULT=YES,AUTOSELECT=YES,FORCED=NO,LANGUAGE="en",URI=vtt_en.m3u8 
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=864000,SUBTITLES="subs" 
                hls-medium.m3u8

and the format the manifest must be something like this

Server .m3u8 file does not include any playlist

Also because you use Amazon you can check some examples from Amazon page