Browse Source

Rework how videojs is initialized

pull/10/head
Gabe Kangas 5 years ago
parent
commit
26760b3be1
  1. 2
      webroot/index.html
  2. 16
      webroot/js/player/player.js

2
webroot/index.html

@ -75,9 +75,7 @@ GW TODO:
playsinline playsinline
muted muted
poster="/thumbnail.png" poster="/thumbnail.png"
data-setup='{}'
> >
<source src="hls/stream.m3u8" type="application/x-mpegURL"/>
</video> </video>
</div> </div>

16
webroot/js/player/player.js

@ -1,16 +1,22 @@
const streamURL = '/hls/stream.m3u8';
// const streamURL = 'https://goth.land/hls/stream.m3u'; // Uncomment me to point to remote video
// style hackings // style hackings
window.VIDEOJS_NO_DYNAMIC_STYLE = true; window.VIDEOJS_NO_DYNAMIC_STYLE = true;
// Wait until the player is setup before we start polling status // Create the player for the first time
const player = videojs('video'); const player = videojs('video', null, function () {
player.on('ready', function () {
console.log('Player ready.')
getStatus(); getStatus();
setInterval(getStatus, 5000); setInterval(getStatus, 5000);
setupPlayerEventHandlers(); setupPlayerEventHandlers();
}) })
player.ready(function () {
console.log('Player ready.')
player.src({ type: 'application/x-mpegURL', src: streamURL });
});
function setupPlayerEventHandlers() { function setupPlayerEventHandlers() {
const player = videojs('video'); const player = videojs('video');

Loading…
Cancel
Save