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

Background playback #7289

Open
HT-7 opened this issue Jun 23, 2022 · 10 comments
Open

Background playback #7289

HT-7 opened this issue Jun 23, 2022 · 10 comments
Labels
enhancement New feature or request web Issues relating to the HTML5 frontend

Comments

@HT-7
Copy link

HT-7 commented Jun 23, 2022

When I switch to a different tab on Newgrounds, Ruffle suspends the flash elements, whereas the original flash kept playing in background. Please bring background playback to Ruffle. Thanks in advance.

@HT-7 HT-7 added the enhancement New feature or request label Jun 23, 2022
@n0samu
Copy link
Member

n0samu commented Jun 24, 2022

Unfortunately, this is not possible due to the restrictions of modern web browsers. Browsers suspend canvas/WebGL elements in the background automatically, and all Ruffle can do is try to cooperate with that.

@mero09-99
Copy link

is this still open by accident?

@n0samu
Copy link
Member

n0samu commented Sep 28, 2022

Well, I've noticed that the swf2js Flash emulator is able to keep playing background music of games while the execution is otherwise suspended. I think this could be cool feature for Ruffle in the future, if it's possible.

@ActionWavele
Copy link

Flash player and SWF2js make it work, so try using JS and Ruffle to do the same!

@n0samu n0samu added the web Issues relating to the HTML5 frontend label Dec 12, 2022
@mlindner
Copy link

Any update on this?

@n0samu
Copy link
Member

n0samu commented Sep 19, 2023

We could probably offer a config option to disable Ruffle's auto-suspend functionality, with the big caveat that Ruffle is still subject to the browser's own auto-suspension as I explained before. So background audio could keep playing, but the game wouldn't otherwise continue running for the most part, which could have strange effects sometimes. I've also been told that a lot of multiplayer Flash games were coded to exchange data with the server at regular intervals, and no matter what we do, this is probably going to be broken for the foreseeable future.

@mlindner
Copy link

mlindner commented Sep 19, 2023

I think that config option would be sufficient. Would that also keep flash video animations playing as well? It wouldn't be good to have the audio and video desync.

@n0samu
Copy link
Member

n0samu commented Sep 19, 2023

I think it would cause desync, unfortunately.

@mlindner
Copy link

There should be a workaround given that there's code that explicitly shuts off the video when it goes into the background.

document.addEventListener(

For example browsers often have options to shut off the feature that causes the issue this code tries to "fix" against.

@n0samu
Copy link
Member

n0samu commented Sep 21, 2023

I already explained that Ruffle pauses itself because otherwise the browser would try to pause it anyway, leading to desyncs and other problems. And I don't believe there are any browser settings to change this, and even if there were, it wouldn't be realistic to expect users to change them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request web Issues relating to the HTML5 frontend
Projects
None yet
Development

No branches or pull requests

5 participants