"Only one player instance playing"
Start here https://github.com/code-for-charity/ImprovedTube-for-YouTube/issues/1516#issuecomment-1436087744 & 2. (Edit by @Improvedtube)
Bug Report:
⚬ BUG: When using the "Only one player instance playing" feature changing to any youtube tab no matter if it is even displaying a video instantly pauses the tab playing a video. ⚬ HOW:
- Enable the "Only one player instance playing" feature.
- Open a tab with a video and start playing it.
- Change active tab to any other youtube tab.
(making a new tab doesnt seem to make it pause, I can even open a video and start playing without Pausing the other one.)
⚬ EXPECTED (/preferred) behavior: Playing youtube video should pause only when I try to play a video in a different tab.
Setup:
⚬ ImprovedTube Version: 3.935 ⚬ Browser: Firefox 107.0.1 ⚬ Settings: Just "Only one player instance playing" on ⚬ OS: Win10
I found out that the problem is when a new tap starts it selects only the video element on the page so the videos node length will always be 1
You can find the code in the general.js file in the content-scripts file. for now, I couldn't find a solution where I can get the video across all tabs in that case the solution will be easy just change the i in the for lobe to 1.
As a temporary solution, I set a counter so I can skip the first time the code run but after that, it works properly
welcome @MohamedLebda thank you!
video across all tabs
please check if it still works in version v3.965 (manifest2) https://github.com/code-for-charity/ImprovedTube-for-YouTube/tree/HEAD@%7B2022-10-07%7D, and what is the difference.
in the last version (manifest version: 2 v3.935), it used different logic, first of all, it doesn't select the video element but its parent and its idea depend on 3 conditions(this.storage.only_one_player_instance_playing, this. focus, ImprovedTube.played_before_blur). when choosing only one player instance it set this.storage.only_one_player_instance_playing: true so that if you open a new tap and choose that tap it sets the other two to true so it fires the player.playVideo() function. But the bug in that version was because of ImprovedTube.played_before_blur, Even without the player element being defined or doing any action the same bug will happen when ImprovedTube.played_before_blur is true. I didn't dig any deeper because it is a different logic than the new version manifest version : 3
3 conditions
thanks again! @MohamedLebda Sorry, i didnt see this is about 3.9* ManiFest2 🙈 4.0.17 works for me without #1562. (While #1562 will make an newly opened tab play at once until any other action happens there. For example advertisment ending, then the new tab will pause). Still #1562 could help in firefox? https://github.com/code-for-charity/ImprovedTube-for-YouTube/issues/1578#issuecomment-1436084112 .
"Only one player playing": (Means by definition,)
- a) Whether clicking "play" in another tab, this should always become the (only) playing tab.
- b) Same for opening a tab with autoplaying video or sound - Unless the user has disabled autoplay* with us ( - or the browser is blocking autoplay of background tabs, like they do by default now*)
- c) in turn it should also unpause again (when going back to a tab previously paused by the feature (not paused by the user)
(this 'c)' works in 3.9x. And works in our "autopause when switching tabs"-feature, based on: played_before_blur
- the only difference here is: a player will only pause, when a another tab is trying to play a video or sound and successfully playing)
BTW we can easily offer this same way for many websites <video> (not only youtube)
*(gotta fix our autoplay:off features too #1508 (autoplay:off) once again comparing: version 3.965.zip (= october7 ) ( or https://greasyfork.org/en/scripts/8123-youtube-click-to-play/code )
while https://github.com/code-charity/youtube/commit/dc56797f195750aaf6b3e2b8028ef6dd97c7bbfb fixes the issue, its not good. It spams non associated tabs with messages. Whats the deal with action: "new-tab-opened"?
cleanup https://github.com/code-charity/youtube/pull/2356 fixes half of https://github.com/code-charity/youtube/issues/2284
action: "new-tab-opened"
we can check in old versions #1658