Skip to content

Sound does not play through headphones on Android and iOS devices #1486

@MichaelNZ85

Description

@MichaelNZ85

Checklist

  • I read the troubleshooting guide before raising this issue
  • I made sure that the issue I am raising doesn't already exist

Current bug behaviour

I created an app that uses the AudioPlayers class to play a beep every 8 seconds. However, when running on an actual physical device, the sound does not come through the headphones, even if they are connected and the main audio output. I tried both Bluetooth and physical headphones on Android, and Bluetooth headphones on iOS - couldn't get the sound to come through them.

Expected behaviour

The sound would be played through the headphones, which are the current audio output device.

Steps to reproduce

  1. Create an app that plays a sound.
  2. Run the app on an physical device (either Android or iOS). Make sure headphones are connected and are the current audio output device.
  3. Play the sound in the app. You should hear nothing through the headphones (or maybe one initial sound, and then none after)

Code sample

Code sample
bool isPlaying = false;
  final player = AudioPlayer();
  AssetSource sound = AssetSource("sounds/beep.wav");

  void _setIsPlaying() {
    setState(() {
      isPlaying = !isPlaying;
    });
  }

  @override
  void initState() {
    Timer timer = Timer.periodic(Duration(seconds: 8), (timer) async {
      if (isPlaying) {
        await player.play(sound);
        print("${DateTime.now()}: Played sound!");
      }
    });
    super.initState();
  }

Affected platforms

Android, iOS

Platform details

  • iPhone XR, iOS 16.0 (20A362)
  • Huawei Y9 Prime 2019 STK-L22, Android 12.0.0.225(C636E2R2P1)

AudioPlayers Version

4.0.1

Build mode

No response

Audio Files/URLs/Sources

No response

Screenshots

No response

Logs

Not applicable as the program runs fine on emulators and also on physical devices, just not playing through headphones

Related issues / more information

No response

Working on PR

Would be happy to help but am not experienced enough with Dart/Flutter to be able to do this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions