feat: add notification controls (#3723)
* feat(ios): add `showNotificationControls` prop * feat(android): add `showNotificationControls` prop * add docs * feat!: add `metadata` property to srouce This is breaking change for iOS/tvOS as we are moving some properties, but I believe that this will more readable and more user friendly * chore(ios): remove UI blocking function * code review changes for android * update example * fix readme * fix typos * update docs * fix typo * chore: improve sample metadata notification * update codegen types * rename properties * update tvOS example * reset metadata on source change * update docs --------- Co-authored-by: Olivier Bouillet <freeboub@gmail.com>
This commit is contained in:
@@ -706,20 +706,23 @@ source={{ uri: 'https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8'
|
||||
|
||||
#### Overriding the metadata of a source
|
||||
|
||||
<PlatformsList types={['tvOS']} />
|
||||
<PlatformsList types={['Android, iOS, tvOS']} />
|
||||
|
||||
Provide an optional `title`, `subtitle`, `customImageUri` and/or `description` properties for the video.
|
||||
Useful when to adapt the tvOS playback experience.
|
||||
Provide an optional `title`, `subtitle`, `artist`, `imageUri` and/or `description` properties for the video.
|
||||
Useful when using notification controls on Android or iOS or to adapt the tvOS playback experience.
|
||||
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
source={{
|
||||
uri: 'https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8',
|
||||
title: 'Custom Title',
|
||||
subtitle: 'Custom Subtitle',
|
||||
description: 'Custom Description',
|
||||
customImageUri: 'https://pbs.twimg.com/profile_images/1498641868397191170/6qW2XkuI_400x400.png'
|
||||
metadata: {
|
||||
title: 'Custom Title',
|
||||
subtitle: 'Custom Subtitle',
|
||||
artist: 'Custom Artist',
|
||||
description: 'Custom Description',
|
||||
imageUri: 'https://pbs.twimg.com/profile_images/1498641868397191170/6qW2XkuI_400x400.png'
|
||||
}
|
||||
}}
|
||||
```
|
||||
|
||||
@@ -780,6 +783,45 @@ textTracks={[
|
||||
]}
|
||||
```
|
||||
|
||||
### `showNotificationContorols`
|
||||
|
||||
<PlatformsList types={['Android', 'iOS']}/>
|
||||
|
||||
Controls whether to show media controls in the notification area.
|
||||
For Android each Video component will have its own notification controls and for iOS only one notification control will be shown for the last Active Video component.
|
||||
|
||||
You propably want also set `playInBackground` to `true` to keep the video playing when the app is in the background or `playWhenInactive` to `true` to keep the video playing when notifications or the Control Center are in front of the video.
|
||||
|
||||
To customize the notification controls you can use `metadata` property in the `source` prop.
|
||||
|
||||
- **false (default)** - Don't show media controls in the notification area
|
||||
- **true** - Show media controls in the notification area
|
||||
|
||||
**To test notification controls on iOS you need to run the app on a real device, as the simulator does not support it.**
|
||||
|
||||
**For Android you have to add the following code in your `AndroidManifest.xml` file:**
|
||||
|
||||
```xml
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
...
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
|
||||
...
|
||||
|
||||
<application>
|
||||
...
|
||||
<service
|
||||
android:name="com.brentvatne.exoplayer.VideoPlaybackService"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="mediaPlayback">
|
||||
<intent-filter>
|
||||
<action android:name="androidx.media3.session.MediaSessionService" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
</application>
|
||||
</manifest>
|
||||
```
|
||||
|
||||
### `useSecureView`
|
||||
|
||||
<PlatformsList types={['Android']} />
|
||||
|
Reference in New Issue
Block a user