问题
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