-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
feat: add notification controls #3723
feat: add notification controls #3723
Conversation
Speaking for android: why do you use custom Notifications with custom actions instead of using the standard |
I want in feature to allow set custom actions |
You can use custom actions with the built-in media session classes: https://developer.android.com/codelabs/supporting-mediasession#4 I believe the built-in one has a huge value, especially to run react-native-video on android tv. |
android/src/main/java/com/brentvatne/exoplayer/VideoPlaybackService.kt
Outdated
Show resolved
Hide resolved
👀 thanks for info, will check out this |
android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java
Outdated
Show resolved
Hide resolved
android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java
Outdated
Show resolved
Hide resolved
android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java
Outdated
Show resolved
Hide resolved
android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java
Outdated
Show resolved
Hide resolved
android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java
Outdated
Show resolved
Hide resolved
android/src/main/java/com/brentvatne/exoplayer/VideoPlaybackService.kt
Outdated
Show resolved
Hide resolved
android/src/main/java/com/brentvatne/exoplayer/VideoPlaybackService.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of small comments, but nothing big to change.
I am just doubting about metadata source. I have never see on my project video with metadata. I really think we should fallback on field provided by the application.
You have 2 choices:
- either use metadata from the source (quick low impact, but not dynamic during playback, and not yet implemented on android)
- either create a new metadata field in the props to allow supporting dynamic update.
And thank you for the PR !
@zoriya seems like I will check if with current implementation, tv pilots will work (I will test it via adb) |
Yes, I tried to use MediaSession from media3 in the draft PR. Is there a reason we can't use it? |
We don't have exoplayer2 any more as we migrated to media3 |
I have tested and with current implementation we support key events like 126, 85 so I guess with this TV should be supported ? |
Yes, since everything was migrated to media3 I don't see why we can't simply use: |
We are using it And I am using |
Okay, I'm sorry I was referring to outdated docs. I got the right one now. I don't understand why you create a notification manually. media3's session support notifications out of the box: https://developer.android.com/media/media3/session/background-playback#notification |
@freeboub I don't see a way to dynamically update metadata... for now I am using |
Ok, thank you for double checking ! |
So I guess in this case will be better to move prop |
@Duell10111 ping for you as I made breaking change for your code for custom metadata. I moved propreties for user metadata from |
@freeboub issue with "metadata reset changing source" should be fixed now (now I am disabling notification controls for player with "no media item" (mostly invalid url/source no view etc.) |
I have tested iOS simulator and it does not support "NowPlayingInfo" notification so I added to docs info that fot iOS you need to run on real device |
@KrzysztofMoch |
@YangJonghun you right, I had not better idea then - we can add this information to docs maybe ? |
I agree it is a good idea! |
Custom notifications require editing the |
@zoriya Your request make sens, but I am 100% sure if need, can you please open a ticket or discussion to discuss about it with @KrzysztofMoch ? (or we can continue here ... ). <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" /> Today, if user doesn't want the feature and don't add it his manifest, will the app still work ? |
That's true, it will always request for permissions. I'm not sure if media notifications is a permission that require user consent or if it is automatically granted. I think this should be opt-out more than opt-in tho, as users, we expect to be able to control media using media buttons. |
@KrzysztofMoch @freeboub @zoriya some of the Player's features require permissions, services, and activities.
Currently, If someone need these features, they have to write within their AndroidManifest.xml. because Android doesn't support programmatically generate Service or Activity
(As far as I know, fyi) if we choose this approach, #3385 can be rewrite with Activity. |
@YangJonghun Thank you for the clue. jetified-media3-session-1.3.1.aar: 506K I am not 100% convinced yet of this necessity :/ |
@freeboub There are two ways to do this: opt-in and opt-out, and currently we choose opt-out, where users specify the permissions and services they need in their code to use certain features. My hypothesis is that react-native-video supports opt-in to improve library user's DX. If it's a regular React-Native library, not a native dependency, you can't specify the service, activity, permission, etc. required for the feature separately. I think opt-in and opt-out are both good!👍 |
As someone said and remove his comment: "You may not but other developers are care about package size" |
Recently, Google Play Console has been requiring proof of app content actually using Foreground Service, so if someone not using it and only have the permission added, this could be a reason for rejection. |
@YangJonghun Thank you for the information ! So I think we should keep implementation as is ! |
@KrzysztofMoch |
On iOS or Android ? |
@KrzysztofMoch |
I think it makes sense - will try to care of it next week |
Summary
Add
showNotificationControls
prop to Android & iOSMotivation
Allow to control video from notification controls
Test plan