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

[BUG]: Android: Notification play control does not request audio focus or pay attention to other audio after one interruption #4209

Open
paulrinaldi opened this issue Oct 1, 2024 · 10 comments

Comments

@paulrinaldi
Copy link
Contributor

paulrinaldi commented Oct 1, 2024

Version

6.6.3

What platforms are you having the problem on?

Android

System Version

14

On what device are you experiencing the issue?

Real device, Simulator

Architecture

Old architecture

What happened?"

Original issue title: Tapping UnPause in Notification Media Controls does not pause external media

Notification Controls do not pause non-RNV media that is currently playing (e.g. YouTube). Additionally, if RNV continues playing after the scenario above, it does not pause when other audio starts playing.

Reproduction Link

https://github.com/TheWidlarzGroup/react-native-video/tree/master/examples/basic

Reproduction

Step to reproduce this bug are:
0. Edit examples/basic/src/VideoPlayer.tsx's rnv videoplayer component's prop playInBackground={false} to playInBackground={true}

  1. Run yarn run android with a simulator open (video player app opens)
  2. Tap to Enable notification controls
  3. Background the app
  4. Open YouTube
  5. Play a video in YouTube to interrupt the RNV AV (observe this interrupt and pause the current video player)
  6. Slide down the notification controls
  7. Tap the play button in the notification controls of RNV

Actual Result:
8. RNV's AV continues while YouTube's AV continues

Expected Result:
8. RNV's AV continues but YouTube's AV is interrupted and pauses

@paulrinaldi paulrinaldi added the bug label Oct 1, 2024
Copy link

github-actions bot commented Oct 1, 2024

Previous bot comment (click to expand)
Previous bot comment (click to expand)
Previous bot comment (click to expand)

Thank you for your bug report. We will review it and get back to you if we need more information.

@paulrinaldi
Copy link
Contributor Author

Looks like we could call setPlayWhenReady(true) in order to request audio focus (see similar resumePlayback() in ReactExoPlayerView.kt). Will try this.

@paulrinaldi
Copy link
Contributor Author

The implementation is more difficult than this.

Additionally if RNV continues playing after the scenario above, it does not pause when other audio starts playing.

After implementing an audio manager and listener in the VideoPlayerService, I still reproduced these bugs. This makes me think of abstracting the service. Will continue to implement a first fix.

This leads me The audio listening must even

@paulrinaldi
Copy link
Contributor Author

@freeboub
Copy link
Collaborator

freeboub commented Oct 1, 2024

@paulrinaldi Thank you for sharing you investigations 🙏

Copy link

github-actions bot commented Oct 2, 2024

Previous bot comment (click to expand)
Previous bot comment (click to expand)

Thank you for your bug report. We will review it and get back to you if we need more information.

@paulrinaldi paulrinaldi changed the title [BUG]: Tapping UnPause in Notification Media Controls does not pause external media [BUG]: Android: Notification play control does not request audio focus or pay attention to other audio after one interruption Oct 3, 2024
Copy link

github-actions bot commented Oct 3, 2024

Previous bot comment (click to expand)

Thank you for your bug report. We will review it and get back to you if we need more information.

There is a newer version of the library available. You are using version 6.6.3, while the latest stable version is 6.6.4. Please update to the latest version and check if the issue still exists.

Note: If the issue still exists, please update the issue report with the latest information.

Copy link

github-actions bot commented Oct 3, 2024

Thank you for your bug report. We will review it and get back to you if we need more information.

There is a newer version of the library available. You are using version 6.6.3, while the latest stable version is 6.6.4. Please update to the latest version and check if the issue still exists.

Note: If the issue still exists, please update the issue report with the latest information.

@paulrinaldi
Copy link
Contributor Author

On android 14+ I realized that handleCommand is not receiving the toggle play event because notifications are build automatically on anything Tiramisu and higher so I need to look into what happens on android 14+.

@paulrinaldi
Copy link
Contributor Author

paulrinaldi commented Oct 4, 2024

For android 12-,
Added a request but this request is not being accepted unfortunately to get control.

For android 14+,
Still wondering why onPause and onPlay in the callback say they do not override anything so I commented them out.

So still not working on either.

Thesis for both is that both do not call requestAudioFocus, biggest struggle I'm facing is implementing that call given my unfamiliarity with Kotlin and Android.
paulrinaldi@a94707f

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

No branches or pull requests

2 participants