TheWidlarzGroup / react-native-video

A <Video /> component for react-native
https://docs.thewidlarzgroup.com/react-native-video/
MIT License
7.2k stars 2.9k forks source link

Managing sound/music from other apps with video components #2737

Open Deodes opened 2 years ago

Deodes commented 2 years ago

Bug

I don't want to disable audio from other app on some <Video/> components, and in some cases I need to disable it. As I see in docs, we have a section "Audio Mixing", which tell us to use:


#import <AVFoundation/AVFoundation.h>  // import

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  ...
  [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil];  // allow
  ...
}

in AppDelegate.m/mm and use ignoreSilentSwitch prop(To be honest, don't understand how it should affect..)

At first it doesn't work personally for me. The second thing is that mixWithOther prop can help in case I need to mix audio, but what am I suppose to do in case, when I actually need to disable sound from other apps?

Platform

Which player are you experiencing the problem on:

Environment info

React native info output:

System:
    OS: macOS 12.3.1
    CPU: (8) arm64 Apple M1
    Memory: 460.67 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 18.0.0 - /opt/homebrew/bin/node
    Yarn: 1.22.17 - /opt/homebrew/bin/yarn
    npm: 8.6.0 - /opt/homebrew/bin/npm
    Watchman: 2022.03.21.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0
    Android SDK:
      API Levels: 23, 28, 29, 30, 31
      Build Tools: 29.0.2, 30.0.2, 31.0.0
      System Images: android-29 | ARM 64 v8a, android-29 | Intel x86 Atom_64, android-29 | Google APIs ARM 64 v8a, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play ARM 64 v8a, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play ARM 64 v8a, android-31 | Google APIs ARM 64 v8a
      Android NDK: Not Found
  IDEs:
    Android Studio: 2020.3 AI-203.7717.56.2031.7784292
    Xcode: 13.1/13A1030d - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.11 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.68.1 => 0.68.1 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Library version: 5.2.0

Steps To Reproduce

  1. Try to use mixWithOther prop or "Audio Mixing" topic from docs for disabling/enabling sound from other apps

Expected behaviour

  1. I can manage sound from other apps manually
BasixKOR commented 12 months ago

I'm unsure about iOS but we have an working implementation of this on our internal patches. I'll follow up a simple PR when I got some time, just commenting here for my own tracking

BasixKOR commented 11 months ago

Here's what we found out by far:

frankusu commented 2 months ago

Almost same here, I'm trying to Play background music when video muted -> stop background music when video unmuted But even with the Appdelegate change and ignoreSilentSwitch. if I have mixWithOther={isVideoMuted ? 'mix' : 'inherit'} the inherit doesn't apply

sentinelweb commented 2 months ago

i believe it should be mixWithOther={isVideoMuted ? 'mix' : 'duck'} - this should lower the background music if the foreground is unmuted