Skip to content

How to prevent sounds if phone is on mute/silent? #50

Open

Description

@jonmountjoy

I'm using the Sounds beta version: 1.0.0.beta13

I guess that many app that plays sound may sometimes want to ensure the app doesn't play sound if the phone is silenced.

I can't find any documentation on this, but digging around some of the platform specific methods, and Apple documentation, I did try this:

      await _soundPlayer.iosSetCategory(
          IOSSessionCategory.soloAambient, IOSSessionMode.defaultMode, 2);

It unfortunately didn't work. The Apple documentation for soloAmbient leads me to believe it's the correct category.

Has anyone managed to ensure sounds stop when on Silent/Mute?

Thanks. If someone can point me in the right direction, I'll document what I find.

Activity

  1. added
    enhancement
    on Oct 9, 2020
  2. bsutton commented on Oct 9, 2020

    @bsutton
    Owner

    Good question and I don't know the answer.

    I should say that we are removing ioscategory from the API as we are looking for the API to be completely platform agnostic.

    So there is a secondary question about what we should exposed to allow sounds to honour the phone being muted.

    Should we honour a muted phone by default?

    Maybe we need to expose a status and event that reflects the mute status.

    I can see scenarios where you want to check if the phone is mute before choosing to play sound and where you are playing audio and want to stop playing it when the phone enters mute mode.
    Then a 'follow' mode what we automatically honour mute mode.

    If course we first have to work out how to detect the state and shy start change.

    I would appreciate any thoughts on the API changes.

  3. jonmountjoy commented on Oct 10, 2020

    @jonmountjoy
    Author

    Those are all good questions @bsutton . I see why you'd want to make this platform agnostic (I much prefer projects that are), but perhaps, like with notifications, there are some irreconcilable differences. Most notification libraries seem to need something platform-specific because the underlying platforms offer different services, like channels or priorities.

    I suppose the same can be said for sound. I didn't realise there were flags for sending stuff to AirPlay for example - and I'm not sure you'll be able to make everything platform agnostic for that reason.

    I guess one approach is to always provide a platform-specific approach, but then also try and find out what the high-level needs are.

    For example, "not playing sounds while muted" feels like something reasonable. Then for those, provide a platform-agnostic way of doing that.

    I wonder if looking at what other cross-platform sound libraries provide (Flutter, React Native, etc.) might be one way to find those needs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions