diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-11-27 21:18:20 -0600 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-11-27 21:18:20 -0600 |
| commit | 1c49fa3b634edd70ed59fc19a7eb540ce63f56bd (patch) | |
| tree | 2f5bf371150563ac12f1bf80c06a18815b5e2728 | |
| parent | 7ab9d741bfc36e19c703ea208a4d39b3a3c78587 (diff) | |
| download | invidious-1c49fa3b634edd70ed59fc19a7eb540ce63f56bd.tar.gz invidious-1c49fa3b634edd70ed59fc19a7eb540ce63f56bd.tar.bz2 invidious-1c49fa3b634edd70ed59fc19a7eb540ce63f56bd.zip | |
Add timeout for autoplay
| -rw-r--r-- | src/invidious/views/components/player.ecr | 24 | ||||
| -rw-r--r-- | src/invidious/views/watch.ecr | 20 |
2 files changed, 24 insertions, 20 deletions
diff --git a/src/invidious/views/components/player.ecr b/src/invidious/views/components/player.ecr index 2c121e02..86a3552f 100644 --- a/src/invidious/views/components/player.ecr +++ b/src/invidious/views/components/player.ecr @@ -142,4 +142,28 @@ player.currentTime(<%= params[:video_start] %>); player.volume(<%= params[:volume].to_f / 100 %>); player.playbackRate(<%= params[:speed] %>); + +<% if params[:autoplay] %> +var bpb = player.getChild('bigPlayButton'); + +if (bpb) { + bpb.hide(); + + player.ready(function() { + new Promise(function(resolve, reject) { + setTimeout(() => resolve(1), 1); + }).then(function(result) { + var promise = player.play(); + + if (promise !== undefined) { + promise.then(_ => { + }).catch(error => { + bpb.show(); + console.log(error); + }); + } + }); + }); +} +<% end %> </script> diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index d3dcb6f8..27a6ba15 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -329,25 +329,6 @@ function get_playlist() { get_playlist(); <% end %> -<% if params[:autoplay] %> -var bpb = player.getChild('bigPlayButton'); - -if (bpb) { - bpb.hide(); - - player.ready(function() { - var promise = player.play(); - - if (promise !== undefined) { - promise.then(_ => { - }).catch(error => { - bpb.show(); - }); - } - }); -} -<% end %> - function get_reddit_comments() { comments = document.getElementById("comments"); var fallback = comments.innerHTML; @@ -523,5 +504,4 @@ function get_youtube_replies(target, load_more) { <% else %> get_youtube_comments(); <% end %> - </script> |
