* fixed autoplay
This commit is contained in:
parent
7ca97901ee
commit
1d4eb2f02a
|
@ -21,4 +21,3 @@
|
|||
</div><h1>Comments</h1>
|
||||
{{.comments_list}}
|
||||
{{.playlist}}
|
||||
<script type='text/javascript' src='js/player.js'></script>
|
||||
|
|
|
@ -20,7 +20,7 @@ window.addEventListener('DOMContentLoaded', (event) => {
|
|||
});
|
||||
console.log(formats);
|
||||
|
||||
if (localStorage.getItem("videoStream") == null) {
|
||||
if (localStorage.getItem("videoStream") == null || localStorage.getItem("videoStream") == "") {
|
||||
const videoFormat = formats.find((fmt) => fmt.vcodec !== 'none');
|
||||
const audioFormat = videoFormat.acodec === 'none' ? formats.find((fmt) => fmt.acodec !== 'none') : null;
|
||||
console.log('selected video format', videoFormat);
|
||||
|
@ -162,10 +162,12 @@ window.addEventListener('DOMContentLoaded', (event) => {
|
|||
}
|
||||
|
||||
function applyStreams() {
|
||||
let autoplayInput = document.querySelector('#autoplayInput');
|
||||
let videoStreamInput = document.querySelector('#videoStreamInput');
|
||||
let audioStreamInput = document.querySelector('#audioStreamInput');
|
||||
localStorage.setItem("videoStream", videoStreamInput.value);
|
||||
localStorage.setItem("audioStream", audioStreamInput.value);
|
||||
localStorage.setItem("autoplay", autoplayInput.checked);
|
||||
|
||||
const videoFormat = formats.find((fmt) => fmt.format_id == videoStreamInput.value);
|
||||
const audioFormat = videoFormat.acodec === 'none' ? formats.find((fmt) => fmt.format_id == audioStreamInput.value) : null;
|
||||
|
@ -247,6 +249,14 @@ window.addEventListener('DOMContentLoaded', (event) => {
|
|||
document.querySelector('.ytp-volume-slider').addEventListener('click', (e) => volume(e));
|
||||
document.querySelector('.ytp-button-fullscreen-enter').addEventListener('click', () => toggleFullscreen());
|
||||
|
||||
// autoplay
|
||||
if(localStorage.getItem("autoplay") == "true") {
|
||||
waiting = setInterval(()=> {
|
||||
if(document.querySelector("video").readyState == 4) {
|
||||
toggleVideo(true);
|
||||
clearInterval(waiting)
|
||||
} else {
|
||||
console.log("waiting...")
|
||||
}
|
||||
},100);
|
||||
}
|
||||
});
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue