-
-
Notifications
You must be signed in to change notification settings - Fork 552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update player.js faster more reliable autoplayDisable #2272
Conversation
This comment was about original
no it doesnt :)
with no effect at all
Have you tested your hyphotesis? Edit :
to read (function waitForPlayer(){if(player=this.elements.player1||videoElement.closest('#movie_player1')){return;} this will always evaluate false because this.elements.player1 doesnt exist and neither any '#movie_player1') now test this code in a debugger :) I already listed 4 problems with it in 2df3a5e 1 you cant block a functions progress by calling settimeout, it just skips it and continues
if(tries++<4){}else if(tries===4) {} will never execute Else clause because var++ is evaluated pre increment, thus you execute (3<4) else (4===4) and on the next loop (4<4) else (5===4) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Increment tldr: javascript doesnt work like that. This youtube/js&css/web-accessible/www.youtube.com/player.js Lines 9 to 14 in 96879c6
just executes
thats why its safer to move it after original play(). |
well this is bad, you pushed this bad code to both builds without testing it crashes because Despite changing order it randomly breaks pause, this is a good time to pull the update |
Pause immediately after play without relinquishing js event loop queue spot (previous settimeout gave browsers opportunity to delay pausing)
Call html video element pause() first, it seems faster?
Finally remove autoplayDeniedOnce. YT is autostarting most videos couple of times, autoplayDeniedOnce was breaking autoplayDisable.
Final result is our autoplayDisable no longer plays up to couple seconds before pausing. Added bonus of moving autoplayDisable below calling original.apply(this, arguments) is any problems in autoplayDisable can no longer prevent/break Play.