diff --git a/templates/themes/default/watch.t b/templates/themes/default/watch.t
index d9f3073..288eb43 100644
--- a/templates/themes/default/watch.t
+++ b/templates/themes/default/watch.t
@@ -21,4 +21,3 @@
Comments
{{.comments_list}}
{{.playlist}}
-
diff --git a/webroot/js/player.js b/webroot/js/player.js
index 30ce26f..ea5e4a1 100644
--- a/webroot/js/player.js
+++ b/webroot/js/player.js
@@ -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);
@@ -30,7 +30,7 @@ window.addEventListener('DOMContentLoaded', (event) => {
} else {
let videoFormat = formats.find((fmt) => fmt.format_id == localStorage.getItem("videoStream"));
if (videoFormat == null) {
- videoFormat = formats.find((fmt) => fmt.vcodec !== 'none');
+ videoFormat = formats.find((fmt) => fmt.vcodec !== 'none');
}
const audioFormat = videoFormat.acodec === 'none' ? formats.find((fmt) => fmt.format_id == localStorage.getItem("audioStream")) : null;
if (audioFormat == null) {
@@ -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
- toggleVideo(true);
+ if(localStorage.getItem("autoplay") == "true") {
+ waiting = setInterval(()=> {
+ if(document.querySelector("video").readyState == 4) {
+ toggleVideo(true);
+ clearInterval(waiting)
+ } else {
+ console.log("waiting...")
+ }
+ },100);
+ }
});
diff --git a/webroot/player.shs b/webroot/player.shs
index 3b18a8e..6928e2e 100755
--- a/webroot/player.shs
+++ b/webroot/player.shs
@@ -25,11 +25,13 @@ echo '
-
+
+
-NaN:NaN
0:00
An error occurred, please try again later.
Learn More
+
'