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

On iOS, there is no audio when playing videos #22

Open
indacurdev opened this issue Aug 7, 2024 · 6 comments
Open

On iOS, there is no audio when playing videos #22

indacurdev opened this issue Aug 7, 2024 · 6 comments
Labels

Comments

@indacurdev
Copy link

I'm trying to use a package to select videos from the gallery and although the video itself plays fine, even if I set the volume to 1, 1.0, 100, etc., the audio is never heard. I even added a slider with the volume control and I didn't get any major results.

@ashilkn
Copy link
Contributor

ashilkn commented Aug 8, 2024

Facing the same issue, audio plays fine on Android.

@ashilkn
Copy link
Contributor

ashilkn commented Aug 8, 2024

@indacurdev Found a fix.

Using the NativeVideoPlayerController, I was first setting the volume and then playing the video.
I flipped this and now audio is working.

  Future<void> _initializeController(
    NativeVideoPlayerController controller,
  ) async {
    _controller = controller;

    controller.onPlaybackEnded.addListener(_onPlaybackEnded);

    final videoSource = await VideoSource.init(
      path: _filePath!,
      type: VideoSourceType.file,
    );
    await controller.loadVideoSource(videoSource);
    await controller.play();
    await controller.setVolume(1);
  }

Update: Now this is also not working. Don't know why it worked for sometime after I made this change. Tested on both debug and profile mode.

@ashilkn
Copy link
Contributor

ashilkn commented Aug 9, 2024

Ah found the reason. Turn off Silent mode.
The device was on Silent mode and that's why audio was muted. Video plays fine with audio on Apple Photos and that is what I was using to check if audio is working for videos on the device.

@albemala
Copy link
Owner

albemala commented Sep 6, 2024

@ashilkn thank you for looking into this and finding a solution.

@indacurdev could you please check ashilkn's solution? thanks

@ashilkn
Copy link
Contributor

ashilkn commented Sep 6, 2024

I found a fix for my issue. Had to set AVAudioSession to playback on iOS for audio to work on silent mode.

Here's the code: https://github.com/ente-io/ente/pull/3037/files

@albemala
Copy link
Owner

albemala commented Jan 3, 2025

@indacurdev @ashilkn I've released a new version of the API, where I address this issue. You can try it here: https://pub.dev/packages/native_video_player/versions/3.0.0-dev.1. Feel free to share your feedback!

P.S. @ashilkn I've included part of your code in the new version, thank you for sharing it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants