AVPlayer not playing m3u8 from local file

I am trying to get AVPlayer to play a m3u8 playlist that is a local file.


I have narrowed this down to a simple test case using one of Apple's sample playlists:


https://tungsten.aaplimg.com/VOD/bipbop_adv_fmp4_example/master.m3u8


If i play this playlist from the remote url, AVPlayer plays this fine. However, if i download this playlist to a local file, and then hand AVPlayer the local file URL, AVPlayer will not play it. It just shows the crossed out play symbol.

Interestingly enough, this can be duplicated with Safari as well. Safari will play the remote playlist but not the local file. Also of note is that this behavior of AVPlayer is identical on iOS 10.2 as well as macOS 10.12.1. Also, playing an mp4 media file directly (not wrapped in a playlist) does not seem to have this issue, as it plays both from a remote URL as well as from a local file.


Inspecting the AVPlayerItem.error does not lead to anything useful either:


An unknown error occurred (-12865) The operation could not be completed 
Is anyone aware of any limitation that AVPlayer would not play a local playlist?


Thank you.

Replies

That's right you can't get m3u8 from the local filesystem. HTTP Live Streaming (HLS - the protocol built around m3u8s) does not let you get the content from the local filesystem. Basically, the naive idea of "I'll just download the files" isn't really workable in general.


However, starting with iOS 10 you can have the systen download HLS content for later playback. This done with AVAssetDownloadURLSession and related classes.

See the "Media Playback Programming Guide" - Working with HTTP Live Streaming

https://developer.apple.com/library/content/documentation/AudioVideo/Conceptual/MediaPlaybackGuide/Contents/Resources/en.lproj/HTTPLiveStreaming/HTTPLiveStreaming.html

Also, the sample code called "HLS Catalog"

and the session "What's New in HTTP Live Streaming" from WWDC 2016

Files with the .m3u8 file extension are the basis for the HTTP Live Streaming format used by Apple to stream video to iOS devices. These files contain MP3 playlist files and they are used by a variety of media applications and online radio stations. These files do not contain any actual audio data. M3U8 files are stored in a plain-text format. Files with the .m3u8 extension are a unicode version of the M3U file format.

Is Anyone got Solution For this?