Giter Club home page Giter Club logo

video-bg-play's Introduction

Video Background Play Fix logo

Firefox for Android can continue playing video even if you switch to another tab or app. However, sites can detect these user actions with the Page Visibility API and the Fullscreen API. This add-on is designed to block events and properties exposed by the APIs.

License

Add-on code: MIT.

"Glasses" icon used in the logo by rahmatmasiv from the Noun Project under the CC BY 3.0 US.

Technical detail

The add-on injects a content script to replace the properties exposed, and stops events from propagating when applicable.

Page Visibility API

The add-on blocks visibilitychange event, and set document.hidden to be always false and document.visibilityState to be forever visible.

Fullscreen API

The add-on doesn't generally override the Fullscreen API because at the moment this is not required and the original implementation caused some broken UI after existing fullscreen. As a site-specific workaround, we do however block fullscreenchange events on Vimeo to prevent playback from stopping when exiting fullscreen.

User activity tracking

Some pages stop playback if they don't detect any user activity for a certain amount of time. To avoid this, the add-on ensures that the time of the last user activity is regularly updated.

Sites

As a demonstration, the content script currently injects itself to the following sites:

  • youtube.com and youtube-nocookie.com
  • vimeo.com

video-bg-play's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

video-bg-play's Issues

Autoplay doesn't work in background on Android (Youtube)

Okay, this is what I just did to reproduce it:

  1. Open a video (and skip to 10 seconds before end)
  2. Open another tab (maybe open sth.)
  3. Go to your Android home screen
  4. Turn the screen off.

When I switch back to the tab, it has either stopped completely.. or the autoplay progress thing continues and then the next video loads..

That said, it happened 3 out of 7 times, so it seems inconsistent. And some of the steps above are probably unnecessary.

The likelihood seems to increase the more videos I watch. For example, just now it stopped after about the fourth video, while the screen was off.

Could it be that the internet connection has something to do with it? (i.e. video starting to buffer or reconnect)

Playlists stopped working

For a few weeks now, the add-on has not worked for YouTube, when Firefox is in the background or the screen is off completely.

I have reset Firefox (clear data from Android's app settings) and reinstalled the add-on but the issue continues. Autoplay is on.

Samsung Galaxy Note 10+
Android 12
Firefox 105.2.0

iOS

Hello,

First, thanks for this addon! Most useful I've got with ublock origin.

Also not a iOS user myself, I am wondering what prevent this bit of code to work in Firefox for iOS?

Cheers

Add TikTok please

Hi,
Addon for FF (107.0.1 64Bit Windows) does not work with Tik Tok Videos, such like: this or this.
Would be great, if it would ;-D

Thank you.

Youtube background stops after a while

Last week I got a new phone (Huawei Honor 10, COL-AL10) which has a newer Android version, 8.1.0
I downloaded the same addon, the firefox does play on background, but after a few songs, it stops.
When I unlock the phone again sometimes it starts playing next song (and I don't even have to open firefox)
But sometimes Youtube in Firefox shows this error "Invalid Response Received"

I looked around my phone, I found a setting which stated that screen off disables some WLAN connections, I disabled it.
Under battery management disabled all savings.
After these change, it still does not work.

There is an app called "stay alive", which is supposed to keep connections alive, but even that does not work and as soon as the phone goes sleep, no more connections pass through.

Currently, I am using an app "touch protector" to keep the screen alive.

Is there some way for your app to disable some settings what I as the user can't change so that my phone never loses connections?
Or my only option is to change Huawei software?
And can I even run for example Pixel 2 software on Huawei or every phone has to have its own software compatible with firmware?

Periodic pauses on YouTube

I am on the 83.0 (Nov 17) build of FF. It is occasionally pausing again, with the message "Video paused. Continue watching?". A test video paused at 39 minutes.

Would like to know if you see anything that's changed in their strategy for blocking background play and if we have a fix.

Fix YouTube TV

The YouTube TV site has recently implemented a similar feature where switching tabs pauses the video. I have tried several extensions that promise to block the Page Awareness API, but with no luck, so I assume they use additional measures to do this.

Perhaps you have any ideas on how to fix it.

Soundcloud

Hi,

Soundcloud is blocking background play unless logged in. It starts working with both the visibilitychange and fullscreenchange, just like vimeo by the looks of it.

Noticed the other issues and the deferring to #3, I'm just reporting anyhow.

Meanwhile as a workaround I made myself a user script https://gitlab.com/-/snippets/2275048/raw/main/soundcloud.user.js (need ff nightly with a user script addon like Firemonkey).

CODE_OF_CONDUCT.md file missing

As of January 1 2019, Mozilla requires that all GitHub projects include this CODE_OF_CONDUCT.md file in the project root. The file has two parts:

  1. Required Text - All text under the headings Community Participation Guidelines and How to Report, are required, and should not be altered.
  2. Optional Text - The Project Specific Etiquette heading provides a space to speak more specifically about ways people can work effectively and inclusively together. Some examples of those can be found on the Firefox Debugger project, and Common Voice. (The optional part is commented out in the raw template file, and will not be visible until you modify and uncomment that part.)

If you have any questions about this file, or Code of Conduct policies and procedures, please see Mozilla-GitHub-Standards or email [email protected].

(Message COC001)

works for a few mins then stops consistently

Hi I'm on Android 13, oneUI 5.1 Samsung and only have partially working addon, it plays in the background for a few minutes and then will stop, it immediately resumes when I return focus to the firefox tab that the video is playing in, I can see the buffering circle when I come back to the tab almost as if it's refusing to buffer unless I return to the video

Addon Disabled in new Firefox for Android 79

Yesterday my Android Firefox update to version 79.0.2 and Video Background Play Fix stop working (is disabled).
Most of my addons (except uBlock Origins) are disabled.
I try the workaround suggested #20 (comment) but sadly don't work.
There is any plan to make this compatible with the new Firefox? or at least any workaround possible?
Thanks!

Add-on won't show up on quick add-on view and has stopped working.

A few days ago the add-on stopped working for me, I was turning my phone on and off a lot that day and was very out of date on my phone but up until then the add-on had been working.

Now while I can play youtube in the background it will not show up in media controls, full screening also hasn't been working and I've had to use auto rotate. The add-on will also not show up on my quick view for add-ons, but on the full add-on page it does, I am unsure how this is related.

I have updated my phone, reinstalled the add-on multiple times and have checked my Firefox is up to date.

I will day that I am unable to test reinstalling Firefox right now as I am logged into important accounts I'm unsure I would be able to get back into right now.

Video gets stuck!!

After video begins playing, I turn of the screen. After a few minutes you hear no sound, check
your video by turning your screen back on and the video shows the spinning circle like it is
buffering data from the internet. Not sure if this is just on long videos, I listen to alot of 3 hour
videos on youtube. Please see this link to test it and any of there daily 3 hour videos.
https://www.youtube.com/watch?v=8wXtAH-kK6w

Thank you!!!!

Compatibility with Firefox 79.0.5 for Android ?

Hello,

I recently updated Firefox to version 79.0.5 for Android 9.
This version does not allow user to browse all the extension, only a selected list.

Is a compatibility with this new version planned ?

Thank you !

Youtube reloads when I receive a call

This addon works perfectly for my Android Firefox browser. Except when I receive a call when a youtube video is playing in the background, the video page gets reloaded as soon as I hang up the call and i lose my watch progress.

"Continue playing" prompt annoyance

Now that, thanks to your effort, we can play longer Youtube videos, I am getting the dreaded "Video paused. Continue watching?" prompt. Obviously, I can't reproduce it at will.

On Chromium for Linux, I am using Youtube Nonstop, an extension with the ID nlkaejimjacpillmajjnopmpbkbnocid . Looking at its source code, it appears that it employs a webworker,with, every two seconds, checks on ($('.html5-video-player').hasClass("paused-mode")). When that turns true, it simulates a $("video").click();. Unfortunately, I don't understand how is the Chromium addon distinguishing between manual pauses and server-imposed pauses.

Site options needed

Please include an option to specify the sites where this extension should kick in.
Right now it seems to be working globally, this is maybe not a good idea for some resource hungry websites using that FF API on mobile devices.

Can ESPN.com support be added?

Hi, ESPN.com has started to stop videos from playing in the background. Can you please add support for ESPN.com to this excellent extension? Thank you

Make extension available for sideloading

After Mozilla latest Firefox for Android update, and the mass disabling of extensions, I migrated to Fennec.
Even though, the extension is not available for download in Mozilla's extensions page.
Could you please make it available for sideloading? Maybe using Github releases feature.

Thank you for your work!

Please add a PIP fix for YouTube.

The Picture-in-picture mode does not work for the website, and I honestly don't know who could fix it better than you guys. This add-on is a fix for video background audio, but maybe you could add a PIP fix for YouTube. Please consider. Thank you :)

This add-ons breaks fullscreen UI elements.

Essentially all of them. Seeking, exiting fullscreen, single and double taps. Sometimes the events go through, other times they don't. Easiest to replicate this in YouTube.

Random replays

Since I installed this extension on desktop, while playing YouTube mixes, every now and then the current video plays twice, sometimes even more times. I think the cause might be that the extension does its work just at the end of the video. I’m certain it’s caused by this extension: I never experienced this before installing the extension, and it’s also gone when I temporarily disabled it. Any idea how to fix it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.