Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: various demo page fixes and enhancements #1186

Merged
merged 11 commits into from
Aug 17, 2021
49 changes: 30 additions & 19 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,23 @@
<div class="tab-content container-fluid">

<div class="tab-pane active" id="sources" role="tabpanel">
<div class="input-group mb-2">
<span class="input-group-text"><label for=load-source>Preloaded Sources</label></span>
<select id=load-source class="form-select">
<optgroup label="hls">
</optgroup>
<optgroup label="dash">
</optgroup>
<optgroup label="drm">
</optgroup>
<optgroup label="live">
</optgroup>
<optgroup label="low latency live">
</optgroup>
<optgroup label="json manifest object">
</optgroup>
</select>
</div>

<label for=url class="form-label">Source URL</label>
<div class="input-group">
Expand All @@ -90,23 +107,6 @@

<button id=load-url type=button class="btn btn-primary my-2">Load</button>

<div class="input-group">
<span class="input-group-text"><label for=load-source>Preloaded Sources</label></span>
<select id=load-source class="form-select">
<optgroup label="hls">
</optgroup>
<optgroup label="dash">
</optgroup>
<optgroup label="drm">
</optgroup>
<optgroup label="live">
</optgroup>
<optgroup label="low latency live">
</optgroup>
<optgroup label="json manifest object">
</optgroup>
</select>
</div>
</div>

<div class="tab-pane" id="options" role="tabpanel">
Expand All @@ -122,7 +122,7 @@
</div>

<div class="form-check">
<input id=liveui type="checkbox" class="form-check-input">
<input id=liveui type="checkbox" class="form-check-input" checked>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

<label class="form-check-label" for="liveui">Enable the live UI (reloads player)</label>
</div>

Expand Down Expand Up @@ -221,9 +221,20 @@
<ul id="segment-metadata" class="col-8"></ul>
</div>
</div>

</div>

<footer class="text-center p-3" id=unit-test-link>
<a href="test/debug.html">Run unit tests</a>
</footer>

<script>
var unitTestLink = document.getElementById('unit-test-link');

// removal test run link on netlify, as we cannot run tests there.
if ((/netlify.app/).test(window.location.host)) {
unitTestLink.remove();
}
</script>
<script src="node_modules/bootstrap/dist/js/bootstrap.js"></script>
<script src="scripts/index.js"></script>
<script>
Expand Down
19 changes: 14 additions & 5 deletions scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,12 @@
};

var setupPlayerStats = function(player) {
player.on('dispose', () => {
if (window.statsTimer) {
window.clearInterval(window.statsTimer);
window.statsTimer = null;
}
});
gkatsev marked this conversation as resolved.
Show resolved Hide resolved
var currentTimeStat = document.querySelector('.current-time-stat');
var bufferedStat = document.querySelector('.buffered-stat');
var videoBufferedStat = document.querySelector('.video-buffered-stat');
Expand Down Expand Up @@ -545,11 +551,6 @@

var mirrorSource = getInputValue(stateEls['mirror-source']);

if (window.statsTimer) {
window.statsTimer = null;
clearInterval(window.statsTimer);
}

player = window.player = window.videojs(videoEl, {
plugins: {
httpSourceSelector: {
Expand All @@ -572,6 +573,14 @@
setupPlayerStats(player);
setupSegmentMetadata(player);

// save player muted state interation
player.on('volumechange', function() {
if (stateEls.muted.checked !== player.muted()) {
stateEls.muted.checked = player.muted();
saveState();
}
});

player.on('sourceset', function() {
var source = player.currentSource();

Expand Down
3 changes: 2 additions & 1 deletion scripts/netlify.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const files = [
'scripts/index.js',
'scripts/old-index.js',
'scripts/dash-manifest-object.json',
'scripts/hls-manifest-object.json'
'scripts/hls-manifest-object.json',
'test/dist/bundle.js'
];

// cleanup previous deploy
Expand Down