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

Playback stops when window loses focus (electron / atom-shell) #57

Closed
kieraneglin opened this issue Dec 11, 2015 · 1 comment
Closed

Comments

@kieraneglin
Copy link

When using the default implementation:

var player = new Player(MUSIC_DIR + currentSong);

player.play(function(err, player){
  if (err) throw (err);
  console.log('playend!');
});

the file plays fine when window is in focus, but when focus is lost, playback stops after a few seconds.

Playback resumes immediately when the window is back in focus, or when I switch between apps.

No errors are being thrown

@kieraneglin
Copy link
Author

Looks like this was an easy fix!

For anyone else with this issue, you can can either disable backgrounding (tells Chromium to not reduce performances (and save CPU cycles) when the window is in background)

Instead of doing that, you can also set the BrowserWindow visibility state to always be in the "visible" state. This saves CPU cycles, but occasionally causes freezing upon your app regaining focus

I got this solution from pracucci.com

Disable backgrounding

var app = require("app");

app.commandLine.appendSwitch("disable-renderer-backgrounding");
app.on("ready", function () {
    // ...
});

Set visible state

new BrowserWindow({
    "web-preferences": {
      "page-visibility": true
    },
    // ...
});

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

No branches or pull requests

1 participant