Skip to content
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

Modification to fix issue #1516 #1587

Merged
merged 5 commits into from
Feb 26, 2023
Merged

Conversation

MohamedLebda
Copy link
Contributor

Now the function doesn't depend on whether the browser block auto play or not.

@ImprovedTube
Copy link
Member

ImprovedTube commented Feb 24, 2023

Thank you! @MohamedLebda

Now the function doesn't depend on whether the browser block auto play or not.

How?

these were obsolete?

action: "new-tab-opened"  

let prevRequestAction = ""; 
prevRequestAction = request.action;

@ImprovedTube
Copy link
Member

BTW, to avoid showing 6 files changed, your repo should pull changes from the master before committing

@MohamedLebda
Copy link
Contributor Author

How?

because now if you open one player instance the autoplay for the other videos will stop so whether it is done by default like firefox or not like chrome(whenever you open a new tap video the other video will play automatically) it will not matter because it will always be off

these were obsolete?

the main reason for those is to detect if a new tap was open and the new tap has video then should not stop playing the main video but the problem was if you open more than one tap at the same time the action played in the background.js that fires the action of new tab opened is after the action tab-connected but chrome. tabs.query({}, function (tabs) is a function from chrome tabs API and it has nothing to do with the action play or not it only sees how many tabs are open right now
bug #1516 background
in this snippet you can see that first, I had two tabs then when I opened another 4 tabs the pervTabs went up from 2 to 6 which means that it will send one message with a new tab opened which is why it worked for only the first tab opened and not if you spend more than that in the same time but in the new code I removed those because now I don't need to send a message to tell me that a new tap is opened instead I made it as a counter to check how many tabs do we have now against what we have before so if we did the same case as the snippet the code will go like this tab length: 6 prev tab length: 2, tab length: 6 prev tab length: 3, tab length: 6 prev tab length: 4 and so on till it equals the current tab length and the message of another video played will only fire when the number of tabs equals the pervTabs which means no other tabs are opening or closing so when the sender id compers with all tabs id as in the snippet
bug #1516 background-1
only the tab id that equals the sender id will not pause and with that logic, the sender id will be the one that you click to play the video in.

The only downside of that code is that if the user opened more than one tab at the same time and didn't wait for them to load and clicks to play the videos on those tabs as fast as he can it can produce a problem that for a split of a second two videos will play at the same time and then they both stop after that it will work fine.

@ImprovedTube ImprovedTube merged commit 654a3ce into code-charity:master Feb 26, 2023
@ImprovedTube
Copy link
Member

if(ImprovedTube.storage.only_one_player_instance_playing === true){
ImprovedTube.storage = {...ImprovedTube.storage, player_autoplay: false, playlist_autoplay: false}
}

permanently disabling autoplay, even if user didnt set this?

( also see "autoplay: only the first video" #1526 )

@ImprovedTube
Copy link
Member

ImprovedTube commented Feb 27, 2023

merged too early. my bad. reverting #1591 for now as of missing lines in #1590

@ImprovedTube ImprovedTube mentioned this pull request Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants