How can I play Apple HLS live stream using html5 video tag

橙三吉。 提交于 2019-11-28 20:03:47

问题


<video id="live"  autoplay controls>
    <source src="http://[WOWZA-IP]:1935/Live/mp4:[LIVESTREAMNAME]/playlist.m3u8" type="video/mp4" />
</video>

I am trying to play h264 encoded live stream using html5 video tag. Live stream is broadcasted by wowza media server and when visiting src link I get a valid playlist file. When trying to play the stream on android chrome browser, player does nothing and shows black screen.

Is this html5 video tag related issue or maybe broadcaster?


回答1:


These are the formats you can play using html5 source tags.

Think of a video format as a zip file which contains the encoded video stream and audio stream. The three formats you should care about for the web are (webm, mp4 and ogv):

.mp4 = H.264 + AAC
.ogg/.ogv = Theora + Vorbis
.webm = VP8 + Vorbis



回答2:


There is actually a good range of solutions for this. One solution would be to detect if HLS can be played:

document.createElement('video').canPlayType('application/vnd.apple.mpegURL') !== ''

However, this would not allow you to play HLS content on devices which do not support playback. At this moment, playback is only supported on Microsoft Edge, iOS Safari, OS X Safari and Android (however, I strongly advise against using HLS on Android due to limitations)

An other solution to play HLS across all platforms in HTML5 is to use an HTML5 HLS player such as THEOplayer. They managed to allow HLS to be played on all popular platforms and devices, including those without Media Source Extension support. Currently, the list of supported browsers and platforms includes: Internet Explorer, Edge, Firefox, Chrome, Opera and Safari on Windows, Linux, Mac OS X, Android, iOS and Windows Phone.




回答3:


On Browsers supporting Media Source Extension you can use https://github.com/dailymotion/hls.js




回答4:


For workarounds using flash, you can use FlasHLS chromeless player.




回答5:


Try FlowPlayer. It provides a full HLS support with the least effort in server side!



来源:https://stackoverflow.com/questions/18434803/how-can-i-play-apple-hls-live-stream-using-html5-video-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!