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

"Only one player instance playing" #1516

Open
hadynpark opened this issue Dec 6, 2022 · 9 comments
Open

"Only one player instance playing" #1516

hadynpark opened this issue Dec 6, 2022 · 9 comments
Labels
bounty Will pass on donations (Optional) - (OR: Requester will pay personally. Only if stated!) Bug Bug or required update after YouTube changes help wanted Just an old github standard we add automatically. (The team can remove it when working on it.) important Critical or common. Thus to prioritize up-for-grabs (a github standard for inviting new contributors) - Welcome! ♥

Comments

@hadynpark
Copy link

hadynpark commented Dec 6, 2022

Start here #1516 (comment) & 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:

  1. Enable the "Only one player instance playing" feature.
  2. Open a tab with a video and start playing it.
  3. 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

@hadynpark hadynpark added Bug Bug or required update after YouTube changes help wanted Just an old github standard we add automatically. (The team can remove it when working on it.) labels Dec 6, 2022
@ImprovedTube ImprovedTube added the up-for-grabs (a github standard for inviting new contributors) - Welcome! ♥ label Dec 6, 2022
@ImprovedTube ImprovedTube added the important Critical or common. Thus to prioritize label Dec 6, 2022
@MohamedLebda
Copy link
Contributor

bug #1516

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

@MohamedLebda
Copy link
Contributor

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.

@MohamedLebda
Copy link
Contributor

bug #1516 temp-solution

As a temporary solution, I set a counter so I can skip the first time the code run but after that, it works properly

@ImprovedTube
Copy link
Member

welcome @MohamedLebda thank you!

@ImprovedTube
Copy link
Member

ImprovedTube commented Feb 8, 2023

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.

@MohamedLebda
Copy link
Contributor

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
bug #1516 manifest 2
bug #1516 manifest-2

MohamedLebda added a commit to MohamedLebda/ImprovedTube-for-YouTube that referenced this issue Feb 11, 2023
MohamedLebda added a commit to MohamedLebda/ImprovedTube-for-YouTube that referenced this issue Feb 12, 2023
@ImprovedTube ImprovedTube removed the up-for-grabs (a github standard for inviting new contributors) - Welcome! ♥ label Feb 19, 2023
ImprovedTube added a commit that referenced this issue Feb 19, 2023
@ImprovedTube ImprovedTube changed the title "Only one player instance playing" Pauses when changing tabs "Only one player instance playing" Feb 19, 2023
@ImprovedTube
Copy link
Member

ImprovedTube commented Feb 19, 2023

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? #1578 (comment) .

"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 )

MohamedLebda added a commit to MohamedLebda/ImprovedTube-for-YouTube that referenced this issue Feb 23, 2023
@MohamedLebda MohamedLebda self-assigned this Feb 23, 2023
MohamedLebda added a commit to MohamedLebda/ImprovedTube-for-YouTube that referenced this issue Feb 25, 2023
MohamedLebda added a commit to MohamedLebda/ImprovedTube-for-YouTube that referenced this issue Mar 3, 2023
MohamedLebda added a commit to MohamedLebda/ImprovedTube-for-YouTube that referenced this issue Mar 3, 2023
MohamedLebda added a commit to MohamedLebda/ImprovedTube-for-YouTube that referenced this issue Mar 4, 2023
MohamedLebda added a commit to MohamedLebda/ImprovedTube-for-YouTube that referenced this issue Mar 17, 2023
@ImprovedTube ImprovedTube added the up-for-grabs (a github standard for inviting new contributors) - Welcome! ♥ label Apr 29, 2023
@ImprovedTube ImprovedTube added the bounty Will pass on donations (Optional) - (OR: Requester will pay personally. Only if stated!) label Nov 5, 2023
@raszpl
Copy link
Contributor

raszpl commented Jun 10, 2024

while dc56797 fixes the issue, its not good. It spams non associated tabs with messages. Whats the deal with action: "new-tab-opened"?
cleanup #2356 fixes half of #2284

@ImprovedTube
Copy link
Member

action: "new-tab-opened"

we can check in old versions #1658

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty Will pass on donations (Optional) - (OR: Requester will pay personally. Only if stated!) Bug Bug or required update after YouTube changes help wanted Just an old github standard we add automatically. (The team can remove it when working on it.) important Critical or common. Thus to prioritize up-for-grabs (a github standard for inviting new contributors) - Welcome! ♥
Projects
Status: No status
Development

No branches or pull requests

4 participants