Skip to content

Commit

Permalink
chore(demo page): add an overrideNative button (default on) (#1027)
Browse files Browse the repository at this point in the history
  • Loading branch information
gkatsev authored Dec 7, 2020
1 parent 27de9a5 commit 197daab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ <h3>Options</h3>
<input id=buffer-water type="checkbox">
[EXPERIMENTAL] Use Buffer Level for ABR (reloads player)
</label>
<label>
<input id=override-native type="checkbox" checked>
Override Native (reloads player)
</label>
</div>

<h3>Load a URL</h3>
Expand Down
14 changes: 11 additions & 3 deletions scripts/index-demo-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@
if (el.type === 'url' || el.type === 'text' || el.nodeName.toLowerCase() === 'textarea') {
el.value = decodeURIComponent(value);
} else {
el.checked = value === 'true' ? true : false;
// get the `value` into a Boolean.
el.checked = JSON.parse(value);
}

};
Expand Down Expand Up @@ -216,7 +217,7 @@
representationsEl.selectedIndex = selectedIndex;
};

['debug', 'autoplay', 'muted', 'minified', 'liveui', 'partial', 'url', 'type', 'keysystems', 'buffer-water'].forEach(function(name) {
['debug', 'autoplay', 'muted', 'minified', 'liveui', 'partial', 'url', 'type', 'keysystems', 'buffer-water', 'override-native'].forEach(function(name) {
stateEls[name] = document.getElementById(name);
});

Expand Down Expand Up @@ -262,6 +263,13 @@
stateEls.minified.dispatchEvent(newEvent('change'));
});

stateEls['override-native'].addEventListener('change', function(event) {
saveState();

// reload the player and scripts
stateEls.minified.dispatchEvent(newEvent('change'));
});

stateEls.liveui.addEventListener('change', function(event) {
saveState();

Expand Down Expand Up @@ -307,7 +315,7 @@
liveui: stateEls.liveui.checked,
html5: {
vhs: {
overrideNative: true,
overrideNative: getInputValue(stateEls['override-native']),
handlePartialData: getInputValue(stateEls.partial),
experimentalBufferBasedABR: getInputValue(stateEls['buffer-water'])
}
Expand Down

0 comments on commit 197daab

Please sign in to comment.