Playback of segmented hls stream with m3u8 playlist

為{幸葍}努か 提交于 2019-12-10 18:33:08

问题


Can mediaelement player play a segmented mpegts hls stream defined in an m3u8 playlist and if so could you show the code to do this. In my case there is a test.m3u8 playlist on a webserver:

#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:7291
#EXTINF:12,
test-7291.ts
#EXTINF:12,
test-7292.ts
#EXTINF:12,
test-7293.ts
#EXTINF:12,
test-7294.ts
#EXTINF:12,
test-7295.ts
#EXTINF:12,
test-7296.ts
#EXTINF:12,
test-7297.ts
#EXTINF:12,
test-7298.ts
#EXTINF:12,
test-7299.ts
#EXTINF:12,
test-7300.ts

iOS devices can view the live stream with no problems.


回答1:


Yes, it can. Put src to .m3u8 in your video tag: <video src="/link/to/your_file.m3u8" />

and init plugin:

var video = document.getElementsByTagName('video')[0];

var player = new MediaElement(video);

Player would start to play from first item in .m3u8 list. Moreover the ability to play m3u8 lists is not mediaelement.js merit, it's platform feature




回答2:


You need to make some changes in the library. You can check out my changes. By just adding m3u8 in the supported formats it seems to work perfectly. https://github.com/sourcebits-harshitakasera/mediaelement-and-player-v2 It seems to work for me.



来源:https://stackoverflow.com/questions/8002344/playback-of-segmented-hls-stream-with-m3u8-playlist

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