mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
Add timeout for autoplay
This commit is contained in:
parent
7ab9d741bf
commit
1c49fa3b63
2 changed files with 24 additions and 20 deletions
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue