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

Safari Changing to different tab not muting sound #266

Open
turkerfatih opened this issue Jun 13, 2024 · 1 comment
Open

Safari Changing to different tab not muting sound #266

turkerfatih opened this issue Jun 13, 2024 · 1 comment

Comments

@turkerfatih
Copy link

Step to reproduce

  1. Open https://pixijs.io/sound/examples/demo.html
  2. Play any loop sound (without clicking anywhere , first click should be playing loop sound)
  3. Switch different tab
    sound is still playing which should not. If you click anywhere after play sound then switch tab it works as expected.

Specs: Safari 17.1 MacOS: Sonoma 14.1.1

@turkerfatih
Copy link
Author

Workaround is the usingvisibilityjs (https://www.npmjs.com/package/visibilityjs)

import * as Visibility  from "visibilityjs";
import { sound } from "@pixi/sound";
Visibility.change((e,s)=>this.onVisibilityChange(e,s));
    private onVisibilityChange(e:Event, state:string)
    {
      if(state=='hidden')
      {
        sound.muteAll()
     
      }else{
        sound.unmuteAll()
      }
    }

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