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

Sound lost/muted when headphones disconnect #175

Open
teejayhh opened this issue Oct 31, 2021 · 3 comments
Open

Sound lost/muted when headphones disconnect #175

teejayhh opened this issue Oct 31, 2021 · 3 comments

Comments

@teejayhh
Copy link

Hello, I dont want to talk around the issue so here it is. Sound is lost when disconnecting headphones from iOS devices.

To reproduce the issue

  • Open https://pixijs.io/sound/examples/ in iOS safari with headphones connected. (I tested on ios14.7, 15.1 but I am sure this is broken in iOS 13 as well).
  • Disconnect the headphones and the sound does not switch to the speaker. You need to reload (refresh the browser) and the sound will work again.

This is a severe issue for our customers, who use our app in a school setting where headphones are mandatory and because the app runs in a webview there isn't a reload page button. I am surprised this has not been flagged before.

Best regards Thomas

@bigtimebuddy
Copy link
Member

Does this still occur if you force HTML Audio instead of Web Audio? You can do this by setting sound.useLegacy = true before loading sounds.

@teejayhh
Copy link
Author

That was my first thought. We will test this out today

@jasedchase
Copy link

jasedchase commented Sep 8, 2023

Try this:

import { sound } from '@pixi/sound';

const context = sound.context.audioContext;

context.onstatechange = ()=> {
    if ((context.state === 'suspended' || context.state === 'interrupted') && document.hasFocus()) {
        context.resume();
    }
};

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

3 participants