javascript - HTTP Live Streaming detection on mobiles -
i want detect if mobile phone/tablet can play http live streaming (m3u8).
i'm testing script:
function ishlsenabled() { var videoelement = document.createelement('video'), canplayappmpeg = videoelement.canplaytype('application/x-mpegurl'), canplayapplempeg = videoelement.canplaytype('vnd.apple.mpegurl'); return ( (canplayappmpeg == 'probably' || canplayappmpeg == 'maybe') || (canplayapplempeg == 'probably' || canplayapplempeg == 'maybe') ); }
but doesn't work on samsung browsers (stock, dolphin, etc) - returns false (because canplaytypes empty strings) able play video.
are there bulletproof(ish) solutions detecting kind of streaming support?
i not sure if there bulletproof solution available @ point.
using video element's canplaytype
method thing 'works'. there around +/- 5/6 media formats have oke support modern browsers.
so create list of formats want support , test them. canplaytype
method allows specify codec. should since testing webm might no lead desired result, example:
element.canplaytype('video/webm; codecs="vp9"')
.
after should 3 different responses: "probably", "mabye" or ""(the empty string meaning: not supported).
some resources might find useful:
mozilla provides list of main stream formats/codec:
modernizr framework test support majority of html5 video formats. might want take @ source code html5 video detection.
Comments
Post a Comment