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

[video_player][ios]: mixWithOthers not working on iOS as it stops the music in the background when video is mounted #94328

Open
obrunsmann opened this issue Nov 29, 2021 · 8 comments
Labels
p: video_player The Video Player plugin P2 Important issues not at the top of the work list package flutter/packages repository. See also p: labels. platform-ios iOS applications specifically team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team

Comments

@obrunsmann
Copy link

obrunsmann commented Nov 29, 2021

We are experiencing strange behavior with the video_player package in latest version 2.2.7:

Expected Behavior:

VideoPlayerController.file(
  file,
  videoPlayerOptions: VideoPlayerOptions(mixWithOthers: true),
);

Using this playing background music with music app or Spotify should continue playing in background while mounting and playing a video in a widget.

Actual behavior:
Music stops 💩

Reproduce:
I was not able to fully reproduce by myself, but what we've got reported from our users was strange. We deployed 3 different versions to our production users:

1)

VideoPlayerController.file(file, videoPlayerOptions: VideoPlayerOptions(mixWithOthers: true))

This stopped music on iOS but worked fine on Android 🤖

2)

VideoPlayerController.file(file)

Worked on iOS, stopped on Android 😬

3)

VideoPlayerController.file(
    file,
    videoPlayerOptions: isAndroid
        ? VideoPlayerOptions(mixWithOthers: true)
        : null,
  )

Stopped on iOS, worked on Android 🦗

In parallel we only further use flutter_tts package, so I am now debugging if there could be a an issue in combination.

Doctor
[✓] Flutter (Channel stable, 2.5.3, on macOS 12.0.1 21A559 darwin-x64, locale de-DE)
    • Flutter version 2.5.3 at /Users/oliver/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (6 weeks ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 13.1, Build version 13A1030d
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).

[✓] VS Code (version 1.62.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.28.0

[✓] Connected device (3 available)
xxx
! Doctor found issues in 2 categories.
@darshankawar darshankawar added the in triage Presently being triaged by the triage team label Nov 30, 2021
@darshankawar
Copy link
Member

@obrunsmann
It seems the video_player plugin doesn't work / support background video or audio playing. Can you try this SO solution and see if it works for you ?

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 30, 2021
@obrunsmann
Copy link
Author

@darshankawar this issue looks like to be the reverse side of my issue.

My issue is that we have a video playing without audio inside the app (while being in foreground) but as soon as the video gets mounted on the screen it pauses spotify or apple music which plays in background.

So there is something not yet 100 % working regarding the mixWithOthers flag and a (shared?) audio session on iOS.
I also tried solving this issue with the audio_session plugin but was not yet successfull while the video_player plugin seems to force create an own audio session or something.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 30, 2021
@darshankawar
Copy link
Member

@obrunsmann
Thanks for the update. I tried a scenario based on above description and can somewhat replicate it. For example:

  1. Play a music on iphone (ex: youtube link)
  2. Run Flutter video player app that has a video without audio.
  3. The music stops alongwith the video

Is this a correct interpretation of your use case ?
Also, I think you are hitting #30438, but withMixOthers parameter.

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Dec 1, 2021
@obrunsmann
Copy link
Author

@darshankawar Yepp - fully correct 👍

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Dec 1, 2021
@darshankawar
Copy link
Member

darshankawar commented Dec 2, 2021

My issue is that we have a video playing without audio inside the app (while being in foreground) but as soon as the video gets mounted on the screen it pauses spotify or apple music which plays in background.

I can see this behavior even without using mixWithOthers parameter and using the official video player plugin example and following the steps to replicate as mentioned #94328 (comment), but also have a doubt if flutter app in general or video player in iOS fully supports playing audio / video in background when app is running. Will keep it open for further insights from the team on expected / intended behavior.

related / similar issue comments for reference:

#30438 (comment)
#30438 (comment)

/cc @cyanglaz @mvanbeusekom

@darshankawar darshankawar added p: first party p: video_player The Video Player plugin platform-ios iOS applications specifically and removed in triage Presently being triaged by the triage team labels Dec 2, 2021
@darshankawar darshankawar changed the title mixWithOthers not working on iOS and strange behaviour [video_player][ios]: mixWithOthers not working on iOS as it stops the music in the background when video is mounted Dec 2, 2021
@stuartmorgan stuartmorgan added the P2 Important issues not at the top of the work list label Dec 2, 2021
@b4tchkn
Copy link

b4tchkn commented Oct 21, 2022

I'm facing the same problem.
It seems that when VideoPlayerController calls initialize, the background audio stops for iOS only.

@clemortel
Copy link

Facing the same problem.
Does anyone found a workaround as the issue is opened form 2021 ?

@stuartmorgan
Copy link
Contributor

If anyone is interested in moving this forward, flutter/plugins#5872 is a starting point for implementing this.

@flutter-triage-bot flutter-triage-bot bot added the package flutter/packages repository. See also p: labels. label Jul 5, 2023
@Hixie Hixie removed the plugin label Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p: video_player The Video Player plugin P2 Important issues not at the top of the work list package flutter/packages repository. See also p: labels. platform-ios iOS applications specifically team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team
Projects
None yet
Development

No branches or pull requests

6 participants