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

Pause audio player on incoming calls or other apps play audio | ios and android #2641

Open
HasanAlyazidi opened this issue Apr 15, 2022 · 6 comments
Labels
triage needed Help needed to confirm the issue

Comments

@HasanAlyazidi
Copy link

Current behavior

The audio does not pause on incoming calls or other apps play audios

Also onAudioFocusChanged does not get called

I tried setting ignoreSilentSwitch to ignore and obey with no luck

Reproduction steps

      <Video
          ref={(ref) => { _PlayerData.player = ref; }}
          source={{ uri }}
          style={styles.player}
          rate={1}
          volume={1}
          paused={!isAudioPlaying()}
          muted={muted}
          repeat={repeat}
          onLoad={this.onLoad}
          onProgress={this.onProgress}
          onError={this.onError}
          onEnd={this.onEnd}
          onAudioBecomingNoisy={this.onAudioBecomingNoisy}
          onAudioFocusChanged={this.onAudioFocusChanged}
          audioOnly
          playInBackground
          playWhenInactive
        />

Expected behavior

My app to pause the audio that is being played on incoming calls or other apps play an audio such as Instagram.

Platform

Which player are you experiencing the problem on:

  • iOS
  • Android ExoPlayer
@hueniverse hueniverse added the triage needed Help needed to confirm the issue label Jun 22, 2022
@zhebil
Copy link

zhebil commented Jul 11, 2022

We have the same problem. Any ideas?

@jeandiasl
Copy link

We have the same problem.

@paulrinaldi
Copy link
Contributor

paulrinaldi commented Apr 2, 2024

We have the same problem. Observed on Android Pixel 7 API level 34, RNV 6.0.0-beta.6. RN 0.73.6.
Reproducible repo:
https://github.com/paulrinaldi/React-Native-Video-With-Expo/tree/background-audio (uses expo)

@paulrinaldi
Copy link
Contributor

paulrinaldi commented Apr 2, 2024

With iOS,

playInBackground
ignoreSilentSwitch='ignore'

And Info.Plist contains:

<key>UIBackgroundModes</key>
	<array>
		<string>audio</string>
	</array>

audio does not continue when backgrounding the sample basic app while it is playing video.

onVideoBuffer is logged after the app is backgrounded via dragging the bar on the button upward on iPhone 15 iOS 17.2

@paulrinaldi
Copy link
Contributor

Making a session manager / exposing some abstraction of the iOS category settings may be helpful here.

@KrzysztofMoch
Copy link
Member

@paulrinaldi I think this could help #3850

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage needed Help needed to confirm the issue
Projects
None yet
Development

No branches or pull requests

6 participants