Created
June 1, 2017 13:28
-
-
Save boyangwang/020f30fa4e0e4c9584fc51a14675ac1e to your computer and use it in GitHub Desktop.
Operate playlist on player level (not video element)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="//player2.h-cdn.com/hola_player.js?customer=demo"></script> | |
</head> | |
<body> | |
<div><h1>Video tag with Hola Player - playing HLS with HolaCDN</h1></div> | |
<video preload="none" class="video-js vjs-default-skin" width="640" height="360" controls> | |
<source src="" type="application/x-mpegurl"> | |
</video> | |
<script> | |
var cur_pos = 0; | |
var playlist = ['http://streamer5.vidgyor.com/vod-origin/vikatan/0_yofu4kbz.smil/playlist.m3u8', | |
'http://player.h-cdn.org/static/hls/oceans/oceans_aes.m3u8', | |
'http://player.h-cdn.org/static/hls/cdn2/master.m3u8']; | |
(function(){ | |
window.hola_player({tech: 'flash'}, function(player){ | |
player.on(['abort', 'canplay', 'canplaythrough', 'componentresize', 'controlsdisabled', 'controlsenabled', 'dispose', 'durationchange', 'emptied', 'ended', 'enterFullWindow', 'error', 'exitFullWindow', 'firstplay', 'fullscreenchange', 'loadeddata', 'loadedmetadata', 'loadstart', 'pause', 'play', 'playing', 'pluginsetup', 'posterchange', 'ready', 'resize', 'seeked', 'seeking', 'stalled', 'suspend', 'tap', 'textdata', 'useractive', 'userinactive', /*'progress', 'timeupdate', */, 'usingcustomcontrols', 'usingnativecontrols', 'volumechange', 'waiting'], | |
function(e){ console.log('xxx', e.type, e); }); | |
player.src(playlist[cur_pos]); | |
player.play(); | |
player.on('ended', function(){ | |
if (cur_pos >= 2) return; | |
cur_pos++; | |
player.src(playlist[cur_pos]); | |
player.load(); | |
player.one('loadedmetadata', function(){ | |
player.play(); | |
}); | |
}); | |
}); | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment