HTML5 video: How to test for HLS playing capability? (video.canPlayType)
However I can’t figure out which ‘type’ is the right one for HLS.
Apple’s Safari HTML5 Audio and Video Guide seems to suggest “vnd.apple.mpegURL” (“Listing 1-7 Falling back to a plug-in for IE”)
<video controls> <source src="https://stackoverflow.com/questions/12410132/HttpLiveStream.m3u8" type="vnd.apple.mpegURL"> <source src="ProgressiveDowload.mp4" type="video/mp4"> ....
canPlayType("vnd.apple.mpegURL") return an empty string even on iOS devices which can play actual HLS streams perfectly fine.
Is there any way to check for playback capabilities without ‘external knowledge’ (e.g. “check for iOS user agent and assume it can play hls”)?
I know I can specify multiple sources in a element and the browser will use the first playable source. However in my case I need feed a single URL to JW Player which I can’t modify. So somehow I need to find the “best playable URL” from a set of video encodings. (An open source JS library which handles source selection would be a nice workaround though.)
I haven’t tested this across the board, but it looks like you should be testing for the full HLS mimetype
application/vnd.apple.mpegURL instead of just just
audio/mpegurl are also suitable mimetypes for the HLS m3u8 file.
audio/x-mpegurl is also listed as an acceptable mimetype according to Apple, but it doesn’t appear to be mentioned in the actual HLS draft spec.
In Safari on iOS and OS X,
maybe. I’m not sure if there are any other browsers that support HLS — Android doesn’t seem to like this syntax (despite some assertions I’ve seen to the contrary), and I believe that it may be due to the fact that the actual video playback is delegated to an external application, rather than the browser itself.