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

PlayerController on iOS plays without sound (physical device only) #349

Closed
KestasVenslauskas opened this issue Oct 23, 2024 · 22 comments
Closed
Labels
bug Something isn't working

Comments

@KestasVenslauskas
Copy link

KestasVenslauskas commented Oct 23, 2024

Describe the bug
If a PlayerController is used to play audio file it plays without sound. It's waveform is visible and you can seek to parts of the audio but there is no sound.
Once you use RecordController and record something then PlayerController starts to work with sound.
This bug happens on physical iOS device only. Tried few different ones the outcome is the same.

To Reproduce

  1. Run the example app
  2. Before you record anything press play on any message
  3. Observe the problem
  4. Additionally - start & stop recording and then try playing any audio again.
  5. Problem is gone.

Expected behavior
Player should play from cold start with sound.

Smartphone (please complete the following information):

  • Device: iPhone6, iPhone10
  • OS: iOS16.0, iOS18.0

Additional context
This bug happens on physical iOS devices only.

@jay-simformsolutions
Copy link
Collaborator

Hi @KestasVenslauskas I have tried your issue from iOS 15 to 17 version but still it's not reproducible. Can you please share minimal reproducible code or more clarification on your issue?

iOS version: 16
device: iPhone 12

RPReplay_Final1729780518.MP4

@jay-simformsolutions jay-simformsolutions added the waiting-for-response Waiting for someone to respond. label Oct 24, 2024
@KestasVenslauskas
Copy link
Author

I am able to reproduce it on the example project no need to any other repo. Not sure what is the trigger for the cause, it's important that you do not try to record before you press play. Even after you pressed record you have to re-build the app, flutter restart is not enough you have to kill the app and this issue should be present on first run

@jay-simformsolutions
Copy link
Collaborator

jay-simformsolutions commented Oct 25, 2024

@KestasVenslauskas As you can see in the shared video, we are unable to reproduce the issue, so we’re unable to dig deeper. Just to double-check, are any other apps playing sound? If that is the case then you may try to use ios AudioSession to override this behavior.

@suesitran
Copy link

I second this issue. The behaviour is exactly as described,

When I use player controller, there's no sound although volume is max and waveform is animated.

But if I turn to record a short audio, then return to play audio, then audio works as normal.

@lqchuong
Copy link

I have the same issue on iOS device

RPReplay_Final1729910169.mp4

@KestasVenslauskas
Copy link
Author

@jay-simformsolutions no luck of reproducing?

@jay-simformsolutions
Copy link
Collaborator

@KestasVenslauskas Yes, this issue is still not reproducible on our end. We will try your steps on different devices and update you once we get any hints about this issue.

If you provide more details on this issue then it will be very helpful for us.

@suesitran
Copy link

I tried to run the example app in my ipad, and here is the screen recording. I turn on sound recording as well to record the sound, both from my voice and from the audio output.

There's no error printed out

RPReplay_Final1730153844.MP4

Flutter doctor

[✓] Flutter (Channel stable, 3.24.3, on macOS 14.0 23A344 darwin-arm64, locale en-AU)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.3)
[✓] VS Code (version 1.92.2)
[✓] Connected device (6 available)
[✓] Network resources

• No issues found!

Pod version: 1.13.0
Dart version: Dart SDK version: 3.5.3 (stable) (Wed Sep 11 16:22:47 2024 +0000) on "macos_arm64"
iPadOS: 18.0.1

@ujas-m-simformsolutions ujas-m-simformsolutions added in triage The issue is being triaged and removed waiting-for-response Waiting for someone to respond. labels Oct 29, 2024
@jay-simformsolutions
Copy link
Collaborator

@KestasVenslauskas, @suesitran, @lqchuong can you please ensure that your device is not in silent mode?

@lqchuong
Copy link

Sure sir, my device is not on silent mode.

@KestasVenslauskas
Copy link
Author

KestasVenslauskas commented Oct 29, 2024 via email

@suesitran
Copy link

I confirm that my device is not in silent mode

@lqchuong
Copy link

@jay-simformsolutions any luck on this issue? :(

@jay-simformsolutions
Copy link
Collaborator

@lqchuong, @KestasVenslauskas, @suesitran can you please try this branch?

audio_waveforms:
  git:
    url: https://github.com/SimformSolutionsPvtLtd/audio_waveforms/tree/fix/ios_audio_play_without_sound

@suesitran
Copy link

@jay-simformsolutions yes that branch works, here is my pubspec.yaml

  audio_waveforms:
    git:
      url: https://github.com/SimformSolutionsPvtLtd/audio_waveforms.git
      ref: fix/ios_audio_play_without_sound

@lqchuong
Copy link

@jay-simformsolutions yupp, that works for me. I think a lot of people have this issue but they don't really realize it, pls merge it asap. Thanks so muchh

@ujas-m-simformsolutions
Copy link
Collaborator

This fix has been merged into the main branch. However, since we couldn’t reproduce the issue on multiple devices, and no other users reported it, we’ve decided not to apply this fix by default. This approach maintains consistency with previous behavior and avoids overriding the user’s existing AudioSession configuration.

To enable this fix, set the following:

playerController.overrideAudioSession = true;

@ujas-m-simformsolutions ujas-m-simformsolutions added the Need to Release Marks the issue which is already fixed but not released on pub.dev label Nov 13, 2024
@yagoquesadafloriach
Copy link

yagoquesadafloriach commented Nov 14, 2024

This fix has been merged into the main branch. However, since we couldn’t reproduce the issue on multiple devices, and no other users reported it, we’ve decided not to apply this fix by default. This approach maintains consistency with previous behavior and avoids overriding the user’s existing AudioSession configuration.

To enable this fix, set the following:

playerController.overrideAudioSession = true;

I have the same issue trying on my iPhone physical device.

  • Device: iPhone 12
  • iOS Version: 17.6.1

With the fix works fine.

@raulmabe-labhouse
Copy link

raulmabe-labhouse commented Nov 19, 2024

playerController.overrideAudioSession = true;

On my physical device this doesn't fix the issue. It works when my bluetooth headphones are connected, but otherwise it does not make any sound even though my volume is at max.

Model iPhone 14 Pro
iOS 17.5.1
Flutter Version is 3.24.0

EDIT: After debugging I achieved to make it work if this code is executed before:

      final session = await AudioSession.instance;
      await session.configure(
        AudioSessionConfiguration(
          avAudioSessionCategory: AVAudioSessionCategory.playAndRecord,
          avAudioSessionCategoryOptions: AVAudioSessionCategoryOptions.allowBluetooth | AVAudioSessionCategoryOptions.defaultToSpeaker,
          avAudioSessionMode: AVAudioSessionMode.spokenAudio,
          avAudioSessionRouteSharingPolicy: AVAudioSessionRouteSharingPolicy.defaultPolicy,
          avAudioSessionSetActiveOptions: AVAudioSessionSetActiveOptions.none,
        ),
      );

It uses this package: https://pub.dev/packages/audio_session.

@ujas-m-simformsolutions ujas-m-simformsolutions removed the Need to Release Marks the issue which is already fixed but not released on pub.dev label Dec 2, 2024
@ujas-m-simformsolutions
Copy link
Collaborator

Fixed in 1.2.0. Please do check it out.

@Ujas-Majithiya
Copy link
Collaborator

@raulmabe-labhouse As mentioned in docs of overrideAudioSession, if you set it to true we will set Audio session category as .playback and mode will be default since you have some different requirement, you will have to set your own audio session as you did with your shared code.

@raulmabe-labhouse
Copy link

raulmabe-labhouse commented Dec 10, 2024

@Ujas-Majithiya I understand I have a different config that what overrideAudioSession does. I still do not understand why playback didn't output any sound on my physical device while on other devices it worked well, that's why I shared my experience. I don't think it is expected tbh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants