2024-03-08 05:04:27 -07:00
import PlatformsList from '../../components/PlatformsList/PlatformsList.tsx';
2024-03-08 04:48:01 -07:00
2023-10-26 00:54:14 -06:00
# Configurable props
2024-03-08 04:48:01 -07:00
This page shows the list of available properties to configure player
2023-10-26 00:54:14 -06:00
## Details
2024-03-08 04:48:01 -07:00
2023-10-26 00:54:14 -06:00
### `adTagUrl`
2024-03-08 04:48:01 -07:00
2024-10-10 15:53:39 -06:00
> [!WARNING]
> Deprecated, use source.ad.adTagUrl instead
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android', 'iOS']} />
2023-10-26 00:54:14 -06:00
Sets the VAST uri to play AVOD ads.
Example:
2024-03-08 04:48:01 -07:00
2023-10-26 00:54:14 -06:00
```
adTagUrl="https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpremidpostoptimizedpodbumper&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&cmsid=496&vid=short_onecue&correlator="
```
2024-01-28 12:03:07 -07:00
Note: You need enable IMA SDK in gradle or pod file - [enable client side ads insertion](/installation)
2023-10-26 00:54:14 -06:00
2024-03-08 04:48:01 -07:00
### `allowsExternalPlayback`
2023-10-26 00:54:14 -06:00
2024-03-08 04:48:01 -07:00
<PlatformsList types={['iOS']} />
2023-10-26 00:54:14 -06:00
Indicates whether the player allows switching to external playback mode such as AirPlay or HDMI.
2024-03-08 04:48:01 -07:00
- **true (default)** - allow switching to external playback mode
- **false** - Don't allow switching to external playback mode
2023-10-26 00:54:14 -06:00
### `audioOutput`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android', 'iOS', 'visionOS']} />
2023-10-26 00:54:14 -06:00
Changes the audio output.
2024-03-08 04:48:01 -07:00
- **speaker (default)** - plays through speaker
- **earpiece** - plays through earpiece
2023-10-26 00:54:14 -06:00
### `automaticallyWaitsToMinimizeStalling`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['iOS', 'visionOS']} />
2023-10-26 00:54:14 -06:00
A Boolean value that indicates whether the player should automatically delay playback in order to minimize stalling. For clients linked against iOS 10.0 and later
2024-03-08 04:48:01 -07:00
- **false** - Immediately starts playback
- **true (default)** - Delays playback in order to minimize stalling
2023-10-26 00:54:14 -06:00
### `bufferConfig`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android']} />
2023-10-26 00:54:14 -06:00
Adjust the buffer settings. This prop takes an object with one or more of the properties listed below.
2024-03-08 04:48:01 -07:00
| Property | Type | Description |
| --------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| minBufferMs | number | The default minimum duration of media that the player will attempt to ensure is buffered at all times, in milliseconds. |
| maxBufferMs | number | The default maximum duration of media that the player will attempt to buffer, in milliseconds. |
| bufferForPlaybackMs | number | The default duration of media that must be buffered for playback to start or resume following a user action such as a seek, in milliseconds. |
| bufferForPlaybackAfterRebufferMs | number | The default duration of media that must be buffered for playback to resume after a rebuffer, in milliseconds. A rebuffer is defined to be caused by buffer depletion rather than a user action. |
2024-03-28 14:33:17 -06:00
| backBufferDurationMs | number | The number of milliseconds of buffer to keep before the current position. This allows rewinding without rebuffering within that duration. |
2024-03-08 04:48:01 -07:00
| maxHeapAllocationPercent | number | The percentage of available heap that the video can use to buffer, between 0 and 1 |
| minBackBufferMemoryReservePercent | number | The percentage of available app memory at which during startup the back buffer will be disabled, between 0 and 1 |
| minBufferMemoryReservePercent | number | The percentage of available app memory to keep in reserve that prevents buffer from using it, between 0 and 1 |
2024-05-01 03:20:34 -06:00
| cacheSizeMB | number | Cache size in MB, enabling this to prevent new src requests and save bandwidth while repeating videos, or 0 to disable. Android only. |
2024-05-20 08:18:20 -06:00
| live | object | Object containing another config set for live playback configuration, see next table |
Description of live object:
| Property | Type | Description |
| --------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| maxPlaybackSpeed | number | The maximum playback speed the player can use to catch up when trying to reach the target live offset. |
| minPlaybackSpeed | number | The minimum playback speed the player can use to fall back when trying to reach the target live offset. |
| maxOffsetMs | number | The maximum allowed live offset. Even when adjusting the offset to current network conditions, the player will not attempt to get above this offset during playback. |
| minOffsetMs | number | The minimum allowed live offset. Even when adjusting the offset to current network conditions, the player will not attempt to get below this offset during playback. |
| targetOffsetMs | number | The target live offset. The player will attempt to get close to this live offset during playback if possible. |
For android, more informations about live configuration can be find [here](https://developer.android.com/media/media3/exoplayer/live-streaming?hl=en)
2023-10-26 00:54:14 -06:00
Example with default values:
2024-03-08 04:48:01 -07:00
2023-10-26 00:54:14 -06:00
```javascript
bufferConfig={{
minBufferMs: 15000,
maxBufferMs: 50000,
bufferForPlaybackMs: 2500,
2024-03-28 14:33:17 -06:00
bufferForPlaybackAfterRebufferMs: 5000,
backBufferDurationMs: 120000,
2024-05-20 08:18:20 -06:00
cacheSizeMB: 0,
live: {
targetOffsetMs: 500,
},
2023-10-26 00:54:14 -06:00
}}
```
2024-05-01 03:20:34 -06:00
Please note that the Android cache is a global cache that is shared among all components; individual components can still opt out of caching behavior by setting cacheSizeMB to 0, but multiple components with a positive cacheSizeMB will be sharing the same one, and the cache size will always be the first value set; it will not change during the app's lifecycle.
2024-05-11 14:02:04 -06:00
### `bufferingStrategy`
<PlatformsList types={['Android']} />
Configure buffering / data loading strategy.
- **Default (default)**: use exoplayer default loading strategy
- **DisableBuffering**: never try to buffer more than needed. Be carefull using this value will stop playback. To be used with care.
- **DependingOnMemory**: use exoplayer default strategy, but stop buffering and starts gc if available memory is low |
2023-10-26 00:54:14 -06:00
### `chapters`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['tvOS']} />
2023-10-26 00:54:14 -06:00
To provide a custom chapter source for tvOS. This prop takes an array of objects with the properties listed below.
| Property | Type | Description |
2024-03-08 04:48:01 -07:00
| --------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
2023-10-26 00:54:14 -06:00
| title | string | The title of the chapter to create |
| startTime | number | The start time of the chapter in seconds |
| endTime | number | The end time of the chapter in seconds |
| uri | string? | Optional: Provide an http orl or the some base64 string to override the image of the chapter. For some media files the images are generated automatically |
2024-03-08 04:48:01 -07:00
### `currentPlaybackTime`
2023-10-26 00:54:14 -06:00
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android', 'iOS']} />
2023-10-26 00:54:14 -06:00
When playing an HLS live stream with a `EXT-X-PROGRAM-DATE-TIME` tag configured, then this property will contain the epoch value in msec.
### `controls`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android', 'iOS', 'visionOS']} />
2023-10-26 00:54:14 -06:00
Determines whether to show player controls.
2024-03-08 04:48:01 -07:00
- **false (default)** - Don't show player controls
- **true** - Show player controls
2023-10-26 00:54:14 -06:00
2024-08-12 05:55:10 -06:00
Controls are always shown in fullscreen mode, even when `controls={false}`.
2023-10-26 00:54:14 -06:00
If needed, you can also add your controls or use a package like [react-native-video-controls](https://github.com/itsnubix/react-native-video-controls) or [react-native-media-console](https://github.com/criszz77/react-native-media-console), see [Useful Side Project](/projects).
2024-05-28 03:58:50 -06:00
### `controlsStyles`
<PlatformsList types={['Android']} />
Adjust the control styles. This prop is need only if `controls={true}` and is an object. See the list of prop supported below.
2024-10-02 15:37:18 -06:00
| Property | Type | Description |
|-------------------------------------|---------|---------------------------------------------------------------------------------------------|
| hidePosition | boolean | Hides the position indicator. Default is `false`. |
| hidePlayPause | boolean | Hides the play/pause button. Default is `false`. |
| hideForward | boolean | Hides the forward button. Default is `false`. |
| hideRewind | boolean | Hides the rewind button. Default is `false`. |
| hideNext | boolean | Hides the next button. Default is `false`. |
| hidePrevious | boolean | Hides the previous button. Default is `false`. |
| hideFullscreen | boolean | Hides the fullscreen button. Default is `false`. |
| hideSeekBar | boolean | The default value is `false`, allowing you to hide the seek bar for live broadcasts. |
| hideDuration | boolean | The default value is `false`, allowing you to hide the duration. |
| hideNavigationBarOnFullScreenMode | boolean | The default value is `true`, allowing you to hide the navigation bar on full-screen mode. |
2024-09-04 01:53:30 -06:00
| hideNotificationBarOnFullScreenMode | boolean | The default value is `true`, allowing you to hide the notification bar on full-screen mode. |
2024-10-05 10:34:25 -06:00
| hideSettingButton | boolean | The default value is `true`, allowing you to hide the setting button. |
2024-10-02 15:37:18 -06:00
| seekIncrementMS | number | The default value is `10000`. You can change the value to increment forward and rewind. |
| liveLabel | string | Allowing you to set a label for live video. |
2024-05-28 03:58:50 -06:00
Example with default values:
```javascript
controlsStyles={{
2024-09-29 12:51:02 -06:00
hidePosition: false,
hidePlayPause: false,
hideForward: false,
hideRewind: false,
hideNext: false,
hidePrevious: false,
hideFullscreen: false,
2024-05-28 03:58:50 -06:00
hideSeekBar: false,
2024-08-21 02:05:40 -06:00
hideDuration: false,
2024-09-04 01:53:30 -06:00
hideNavigationBarOnFullScreenMode: true,
hideNotificationBarOnFullScreenMode: true,
2024-10-05 10:34:25 -06:00
hideSettingButton: true,
2024-09-29 12:51:02 -06:00
seekIncrementMS: 10000,
2024-10-02 15:37:18 -06:00
liveLabel: "LIVE"
2024-05-28 03:58:50 -06:00
}}
```
2023-10-26 00:54:14 -06:00
### `contentStartTime`
2024-09-14 11:53:54 -06:00
> [!WARNING]
> Deprecated, use source.contentStartTime instead
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android']} />
The start time in ms for SSAI content. This determines at what time to load the video info like resolutions. Use this only when you have SSAI stream where ads resolution is not the same as content resolution.
2024-09-14 11:53:54 -06:00
Note: This feature only works on DASH streams
2023-10-26 00:54:14 -06:00
### `debug`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android']} />
2023-10-26 00:54:14 -06:00
Enable more verbosity in logs.
> [!WARNING]
> Do not use this open in production build
2024-03-08 04:48:01 -07:00
| Property | Type | Description |
| -------- | ------- | --------------------------------------------- |
| `enable` | boolean | when true, display logs with verbosity higher |
| `thread` | boolean | enable thread display |
2023-10-26 00:54:14 -06:00
Example with default values:
2024-03-08 04:48:01 -07:00
2023-10-26 00:54:14 -06:00
```javascript
debug={{
enable: true,
thread: true,
}}
```
### `disableFocus`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android']} />
2023-10-26 00:54:14 -06:00
Determines whether video audio should override background music/audio in Android devices.
2024-03-08 04:48:01 -07:00
- **false (default)** - Override background audio/music
- **true** - Let background audio/music from other apps play
2023-10-26 00:54:14 -06:00
Note: Allows multiple videos to play if set to `true`. If `false`, when one video is playing and another is started, the first video will be paused.
### `disableDisconnectError`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android']} />
2023-10-26 00:54:14 -06:00
Determines if the player needs to throw an error when connection is lost or not
2024-03-08 04:48:01 -07:00
- **false (default)** - Player will throw an error when connection is lost
- **true** - Player will keep trying to buffer when network connect is lost
2023-10-26 00:54:14 -06:00
2024-05-04 06:36:39 -06:00
### `drm`
2024-03-08 04:48:01 -07:00
2024-07-10 04:17:22 -06:00
> [!WARNING]
> deprecated, use source.drm instead
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android', 'iOS']} />
2023-10-26 00:54:14 -06:00
To setup DRM please follow [this guide](/component/drm)
2024-01-15 23:21:38 -07:00
> ⚠️ DRM is not supported on visionOS yet
2023-10-26 00:54:14 -06:00
### `filter`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['iOS', 'visionOS']} />
2023-10-26 00:54:14 -06:00
Add video filter
2024-03-08 04:48:01 -07:00
- **FilterType.NONE (default)** - No Filter
- **FilterType.INVERT** - CIColorInvert
- **FilterType.MONOCHROME** - CIColorMonochrome
- **FilterType.POSTERIZE** - CIColorPosterize
- **FilterType.FALSE** - CIFalseColor
- **FilterType.MAXIMUMCOMPONENT** - CIMaximumComponent
- **FilterType.MINIMUMCOMPONENT** - CIMinimumComponent
- **FilterType.CHROME** - CIPhotoEffectChrome
- **FilterType.FADE** - CIPhotoEffectFade
- **FilterType.INSTANT** - CIPhotoEffectInstant
- **FilterType.MONO** - CIPhotoEffectMono
- **FilterType.NOIR** - CIPhotoEffectNoir
- **FilterType.PROCESS** - CIPhotoEffectProcess
- **FilterType.TONAL** - CIPhotoEffectTonal
- **FilterType.TRANSFER** - CIPhotoEffectTransfer
- **FilterType.SEPIA** - CISepiaTone
2023-10-26 00:54:14 -06:00
For more details on these filters refer to the [iOS docs](https://developer.apple.com/library/archive/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/uid/TP30000136-SW55).
2024-03-08 04:48:01 -07:00
Notes:
2023-10-26 00:54:14 -06:00
1. Using a filter can impact CPU usage. A workaround is to save the video with the filter and then load the saved video.
2. Video filter is currently not supported on HLS playlists.
3. `filterEnabled` must be set to `true`
### `filterEnabled`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['iOS', 'visionOS']} />
2023-10-26 00:54:14 -06:00
2024-03-08 04:48:01 -07:00
Enable video filter.
- **false (default)** - Don't enable filter
- **true** - Enable filter
2023-10-26 00:54:14 -06:00
2024-05-04 06:36:39 -06:00
### `focusable`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android']} />
2023-10-26 00:54:14 -06:00
Whether this video view should be focusable with a non-touch input device, eg. receive focus with a hardware keyboard.
2024-03-08 04:48:01 -07:00
- **false** - Makes view unfocusable
- **true (default)** - Makes view focusable
2023-10-26 00:54:14 -06:00
### `fullscreen`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android', 'iOS', 'visionOS']} />
2023-10-26 00:54:14 -06:00
Controls whether the player enters fullscreen on play.
See [presentFullscreenPlayer](#presentfullscreenplayer) for details.
2024-03-08 04:48:01 -07:00
- **false (default)** - Don't display the video in fullscreen
- **true** - Display the video in fullscreen
2023-10-26 00:54:14 -06:00
### `fullscreenAutorotate`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['iOS', 'visionOS']} />
If a preferred [fullscreenOrientation](#fullscreenorientation) is set, causes the video to rotate to that orientation but permits rotation of the screen to orientation held by user. Defaults to TRUE.
2023-10-26 00:54:14 -06:00
### `fullscreenOrientation`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['iOS', 'visionOS']} />
2023-10-26 00:54:14 -06:00
2024-03-08 04:48:01 -07:00
- **all (default)** -
- **landscape**
- **portrait**
2023-10-26 00:54:14 -06:00
### `headers`
2024-03-08 04:48:01 -07:00
2024-05-22 14:59:32 -06:00
<PlatformsList types={['iOS', 'Android']} />
2024-03-08 04:48:01 -07:00
Pass headers to the HTTP client. Can be used for authorization. Headers must be a
part of the source object.
2023-10-26 00:54:14 -06:00
Example:
2024-03-08 04:48:01 -07:00
2023-10-26 00:54:14 -06:00
```javascript
source={{
uri: "https://www.example.com/video.mp4",
headers: {
Authorization: 'bearer some-token-value',
'X-Custom-Header': 'some value'
}
}}
```
### `hideShutterView`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android']} />
Controls whether the ExoPlayer shutter view (black screen while loading) is enabled.
2023-10-26 00:54:14 -06:00
2024-03-08 04:48:01 -07:00
- **false (default)** - Show shutter view
- **true** - Hide shutter view
2023-10-26 00:54:14 -06:00
### `ignoreSilentSwitch`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['iOS', 'visionOS']} />
2023-10-26 00:54:14 -06:00
Controls the iOS silent switch behavior
2024-03-08 04:48:01 -07:00
- **"inherit" (default)** - Use the default AVPlayer behavior
- **"ignore"** - Play audio even if the silent switch is set
- **"obey"** - Don't play audio if the silent switch is set
2023-10-26 00:54:14 -06:00
2024-05-04 06:36:39 -06:00
2023-10-26 00:54:14 -06:00
### `maxBitRate`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android', 'iOS', 'visionOS']} />
2023-10-26 00:54:14 -06:00
Sets the desired limit, in bits per second, of network bandwidth consumption when multiple video streams are available for a playlist.
Default: 0. Don't limit the maxBitRate.
2024-09-17 07:57:26 -06:00
Note: This property can interact with selectedVideoTrack.
To use `maxBitrate`, selectedVideoTrack shall be undefined or `{type: SelectedVideoTrackType.AUTO}`.
2023-10-26 00:54:14 -06:00
Example:
2024-03-08 04:48:01 -07:00
2023-10-26 00:54:14 -06:00
```javascript
maxBitRate={2000000} // 2 megabits
```
### `minLoadRetryCount`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android']} />
2023-10-26 00:54:14 -06:00
Sets the minimum number of times to retry loading data before failing and reporting an error to the application. Useful to recover from transient internet failures.
Default: 3. Retry 3 times.
Example:
2024-03-08 04:48:01 -07:00
2023-10-26 00:54:14 -06:00
```javascript
minLoadRetryCount={5} // retry 5 times
```
### `mixWithOthers`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['iOS', 'visionOS']} />
2023-10-26 00:54:14 -06:00
Controls how Audio mix with other apps.
2024-03-08 04:48:01 -07:00
- **"inherit" (default)** - Use the default AVPlayer behavior
- **"mix"** - Audio from this video mixes with audio from other apps.
- **"duck"** - Reduces the volume of other apps while audio from this video plays.
2023-10-26 00:54:14 -06:00
### `muted`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['All']} />
2023-10-26 00:54:14 -06:00
Controls whether the audio is muted
2024-03-08 04:48:01 -07:00
- **false (default)** - Don't mute audio
- **true** - Mute audio
2023-10-26 00:54:14 -06:00
### `paused`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['All']} />
2023-10-26 00:54:14 -06:00
Controls whether the media is paused
2024-03-08 04:48:01 -07:00
- **false (default)** - Don't pause the media
- **true** - Pause the media
2023-10-26 00:54:14 -06:00
### `pictureInPicture`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['iOS']} />
2023-10-26 00:54:14 -06:00
Determine whether the media should played as picture in picture.
2024-03-08 04:48:01 -07:00
- **false (default)** - Don't not play as picture in picture
- **true** - Play the media as picture in picture
2023-10-26 00:54:14 -06:00
2024-03-08 04:48:01 -07:00
NOTE: Video ads cannot start when you are using the PIP on iOS (more info available at [Google IMA SDK Docs](https://developers.google.com/interactive-media-ads/docs/sdks/ios/client-side/picture_in_picture?hl=en#starting_ads)). If you are using custom controls, you must hide your PIP button when you receive the `STARTED` event from `onReceiveAdEvent` and show it again when you receive the `ALL_ADS_COMPLETED` event.
2023-10-26 00:54:14 -06:00
### `playInBackground`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android', 'iOS', 'visionOS']} />
2023-10-26 00:54:14 -06:00
Determine whether the media should continue playing while the app is in the background. This allows customers to continue listening to the audio.
2024-03-08 04:48:01 -07:00
- **false (default)** - Don't continue playing the media
- **true** - Continue playing the media
2023-10-26 00:54:14 -06:00
To use this feature on iOS, you must:
2024-03-08 04:48:01 -07:00
- [Enable Background Audio](https://developer.apple.com/library/archive/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/AudioSessionBasics/AudioSessionBasics.html#//apple_ref/doc/uid/TP40007875-CH3-SW3) in your Xcode project
- Set the ignoreSilentSwitch prop to "ignore"
2023-10-26 00:54:14 -06:00
### `playWhenInactive`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['iOS', 'visionOS']} />
2023-10-26 00:54:14 -06:00
Determine whether the media should continue playing when notifications or the Control Center are in front of the video.
2024-03-08 04:48:01 -07:00
- **false (default)** - Don't continue playing the media
- **true** - Continue playing the media
2023-10-26 00:54:14 -06:00
### `poster`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['All']} />
2024-07-22 14:38:35 -06:00
> [!WARNING]
> Value: string with a URL for the poster is deprecated, use `poster` as object instead
2024-03-08 04:48:01 -07:00
2023-10-26 00:54:14 -06:00
An image to display while the video is loading
2024-07-22 14:38:35 -06:00
Value: Props for the `Image` component. The poster is visible when the source attribute is provided.
2023-10-26 00:54:14 -06:00
2024-07-22 14:38:35 -06:00
```javascript
<Video>
poster={{
source: { uri: "https://baconmockup.com/300/200/" },
resizeMode: "cover",
// ...
}}
</Video>
````
2024-03-08 04:48:01 -07:00
2024-07-22 14:38:35 -06:00
### `posterResizeMode`
> [!WARNING]
> deprecated, use `poster` with `resizeMode` key instead
2024-03-08 04:48:01 -07:00
<PlatformsList types={['All']} />
2023-10-26 00:54:14 -06:00
Determines how to resize the poster image when the frame doesn't match the raw video dimensions.
2024-03-08 04:48:01 -07:00
- **"contain" (default)** - Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or less than the corresponding dimension of the view (minus padding).
- **"center"** - Center the image in the view along both dimensions. If the image is larger than the view, scale it down uniformly so that it is contained in the view.
- **"cover"** - Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding).
- **"none"** - Don't apply resize
- **"repeat"** - Repeat the image to cover the frame of the view. The image will keep its size and aspect ratio. (iOS only)
- **"stretch"** - Scale width and height independently, This may change the aspect ratio of the src.
2023-10-26 00:54:14 -06:00
### `preferredForwardBufferDuration`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['iOS', 'visionOS']} />
2023-10-26 00:54:14 -06:00
The duration the player should buffer media from the network ahead of the playhead to guard against playback disruption. Sets the [preferredForwardBufferDuration](https://developer.apple.com/documentation/avfoundation/avplayeritem/1643630-preferredforwardbufferduration) instance property on AVPlayerItem.
Default: 0
### `preventsDisplaySleepDuringVideoPlayback`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['iOS', 'Android']} />
2023-10-26 00:54:14 -06:00
Controls whether or not the display should be allowed to sleep while playing the video. Default is not to allow display to sleep.
Default: true
### `progressUpdateInterval`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['All']} />
2023-10-26 00:54:14 -06:00
Delay in milliseconds between onProgress events in milliseconds.
Default: 250.0
### `rate`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['All']} />
Speed at which the media should play.
2024-03-21 08:40:25 -06:00
- **0.0** - Pauses the video (iOS only)
- **1.0** - Play at normal speed (default)
2024-03-08 04:48:01 -07:00
- **Other values** - Slow down or speed up playback
2023-10-26 00:54:14 -06:00
2024-07-22 14:38:35 -06:00
### `renderLoader`
<PlatformsList types={['All']} />
2024-09-17 07:58:47 -06:00
Allows you to create custom components to display while the video is loading.
If `renderLoader` is provided, `poster` and `posterResizeMode` will be ignored.
renderLoader is either a component or a function returning a component.
It is recommended to use the function for optimization matter.
2024-09-29 12:51:02 -06:00
`renderLoader` function be called with parameters of type `ReactVideoRenderLoaderProps` to be able to adapt loader
2024-09-17 07:58:47 -06:00
```typescript
interface ReactVideoRenderLoaderProps {
source?: ReactVideoSource; /// source of the video
style?: StyleProp<ImageStyle>; /// style to apply
resizeMode?: EnumValues<VideoResizeMode>; /// resizeMode provided to the video component
}
````
Sample:
2024-07-22 14:38:35 -06:00
```javascript
<Video>
2024-09-17 07:58:47 -06:00
renderLoader={() => (
2024-07-22 14:38:35 -06:00
<View>
<Text>Custom Loader</Text>
2024-09-17 07:58:47 -06:00
</View>)
2024-07-22 14:38:35 -06:00
}
</Video>
````
2023-10-26 00:54:14 -06:00
### `repeat`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['All']} />
2023-10-26 00:54:14 -06:00
2024-03-08 04:48:01 -07:00
Determine whether to repeat the video when the end is reached
- **false (default)** - Don't repeat the video
- **true** - Repeat the video
2023-10-26 00:54:14 -06:00
2024-03-08 04:48:01 -07:00
### `reportBandwidth`
2023-10-26 00:54:14 -06:00
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android']} />
2023-10-26 00:54:14 -06:00
Determine whether to generate onBandwidthUpdate events. This is needed due to the high frequency of these events on ExoPlayer.
2024-03-08 04:48:01 -07:00
- **false (default)** - Don't generate onBandwidthUpdate events
- **true** - Generate onBandwidthUpdate events
2023-10-26 00:54:14 -06:00
### `resizeMode`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android', 'iOS', 'Windows UWP']} />
2023-10-26 00:54:14 -06:00
Determines how to resize the video when the frame doesn't match the raw video dimensions.
2024-03-08 04:48:01 -07:00
- **"none" (default)** - Don't apply resize
- **"contain"** - Scale the video uniformly (maintain the video's aspect ratio) so that both dimensions (width and height) of the video will be equal to or less than the corresponding dimension of the view (minus padding).
- **"cover"** - Scale the video uniformly (maintain the video's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding).
- **"stretch"** - Scale width and height independently, This may change the aspect ratio of the src.
2023-10-26 00:54:14 -06:00
### `selectedAudioTrack`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android', 'iOS', 'visionOS']} />
2023-10-26 00:54:14 -06:00
Configure which audio track, if any, is played.
```javascript
selectedAudioTrack={{
type: Type,
value: Value
}}
```
Example:
2024-03-08 04:48:01 -07:00
2023-10-26 00:54:14 -06:00
```javascript
selectedAudioTrack={{
type: "title",
value: "Dubbing"
}}
```
2024-03-08 04:48:01 -07:00
| Type | Value | Description |
| ------------------ | ------ | ------------------------------------------------------------------------------------------- |
| "system" (default) | N/A | Play the audio track that matches the system language. If none match, play the first track. |
| "disabled" | N/A | Turn off audio |
| "title" | string | Play the audio track with the title specified as the Value, e.g. "French" |
| "language" | string | Play the audio track with the language specified as the Value, e.g. "fr" |
| "index" | number | Play the audio track with the index specified as the value, e.g. 0 |
2023-10-26 00:54:14 -06:00
If a track matching the specified Type (and Value if appropriate) is unavailable, the first audio track will be played. If multiple tracks match the criteria, the first match will be used.
### `selectedTextTrack`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android', 'iOS', 'visionOS']} />
2023-10-26 00:54:14 -06:00
Configure which text track (caption or subtitle), if any, is shown.
```javascript
selectedTextTrack={{
type: Type,
value: Value
}}
```
Example:
2024-03-08 04:48:01 -07:00
2023-10-26 00:54:14 -06:00
```javascript
selectedTextTrack={{
type: "title",
value: "English Subtitles"
}}
```
2024-03-08 04:48:01 -07:00
| Type | Value | Description |
| ------------------ | ------ | ----------------------------------------------------------------------------- |
| "system" (default) | N/A | Display captions only if the system preference for captions is enabled |
| "disabled" | N/A | Don't display a text track |
| "title" | string | Display the text track with the title specified as the Value, e.g. "French 1" |
| "language" | string | Display the text track with the language specified as the Value, e.g. "fr" |
| "index" | number | Display the text track with the index specified as the value, e.g. 0 |
2023-10-26 00:54:14 -06:00
2024-03-08 04:48:01 -07:00
Both iOS & Android (only 4.4 and higher) offer Settings to enable Captions for hearing impaired people. If "system" is selected and the Captions Setting is enabled, iOS/Android will look for a caption that matches that customer's language and display it.
2023-10-26 00:54:14 -06:00
If a track matching the specified Type (and Value if appropriate) is unavailable, no text track will be displayed. If multiple tracks match the criteria, the first match will be used.
### `selectedVideoTrack`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android']} />
2023-10-26 00:54:14 -06:00
Configure which video track should be played. By default, the player uses Adaptive Bitrate Streaming to automatically select the stream it thinks will perform best based on available bandwidth.
```javascript
selectedVideoTrack={{
type: Type,
value: Value
}}
```
Example:
2024-03-08 04:48:01 -07:00
2023-10-26 00:54:14 -06:00
```javascript
selectedVideoTrack={{
type: "resolution",
value: 480
}}
```
2024-03-08 04:48:01 -07:00
| Type | Value | Description |
| ---------------- | ------ | ---------------------------------------------------------------------------- |
| "auto" (default) | N/A | Let the player determine which track to play using ABR |
| "disabled" | N/A | Turn off video |
| "resolution" | number | Play the video track with the height specified, e.g. 480 for the 480p stream |
| "index" | number | Play the video track with the index specified as the value, e.g. 0 |
2023-10-26 00:54:14 -06:00
If a track matching the specified Type (and Value if appropriate) is unavailable, ABR will be used.
### `shutterColor`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android']} />
Apply color to shutter view, if you see black flashes before video start then set
2023-10-26 00:54:14 -06:00
```javascript
2024-03-08 04:48:01 -07:00
shutterColor = 'transparent';
2023-10-26 00:54:14 -06:00
```
- black (default)
### `source`
2024-03-08 04:48:01 -07:00
2023-10-26 00:54:14 -06:00
Sets the media source. You can pass an asset loaded via require or an object with a uri.
Setting the source will trigger the player to attempt to load the provided media with all other given props. Please be sure that all props are provided before/at the same time as setting the source.
Rendering the player component with a null source will init the player, and start playing once a source value is provided.
Providing a null source value after loading a previous source will stop playback, and clear out the previous source content.
The docs for this prop are incomplete and will be updated as each option is investigated and tested.
#### Asset loaded via require
2023-11-17 07:38:32 -07:00
> ⚠️ on iOS, you file name must not contain spaces eg. `my video.mp4` will not work, use `my-video.mp4` instead
2024-03-08 04:48:01 -07:00
Example:
2024-03-13 01:23:11 -06:00
Pass directly the asset to play (deprecated)
2023-10-26 00:54:14 -06:00
```javascript
const sintel = require('./sintel.mp4');
2024-05-01 03:20:34 -06:00
source = {sintel};
2024-03-13 01:23:11 -06:00
```
Or by using an uri (starting from 6.0.0-beta.6)
2023-10-26 00:54:14 -06:00
2024-03-13 01:23:11 -06:00
```javascript
const sintel = require('./sintel.mp4');
source={{ uri: sintel }}
2023-10-26 00:54:14 -06:00
```
#### URI string
A number of URI schemes are supported by passing an object with a `uri` attribute.
2023-12-24 06:38:33 -07:00
All uri string shall be url encoded.
For exemple 'www.myurl.com/blabla?q=test uri' is invalid, where 'www.myurl.com/blabla?q=test%20uri' is valid
2023-10-26 00:54:14 -06:00
##### Web address (http://, https://)
2024-03-08 04:48:01 -07:00
<PlatformsList types={['All']} />
2023-10-26 00:54:14 -06:00
Example:
2024-03-08 04:48:01 -07:00
2023-10-26 00:54:14 -06:00
```javascript
source={{uri: 'https://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_10mb.mp4' }}
```
##### File path (file://)
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android']} />
2023-10-26 00:54:14 -06:00
Example:
2024-03-08 04:48:01 -07:00
2023-10-26 00:54:14 -06:00
```javascript
source={{ uri: 'file:///sdcard/Movies/sintel.mp4' }}
```
Note: Your app will need to request permission to read external storage if you're accessing a file outside your app.
2024-05-06 13:51:17 -06:00
##### File from asset folder (asset://)
<PlatformsList types={['Android']} />
Allows to play a video file from the asset folder from the application
Example:
```javascript
source={{ uri: 'asset:///sintel.mp4' }}
```
2023-10-26 00:54:14 -06:00
##### iPod Library (ipod-library://)
2024-03-08 04:48:01 -07:00
<PlatformsList types={['iOS']} />
2023-10-26 00:54:14 -06:00
Path to a sound file in your iTunes library. Typically shared from iTunes to your app.
Example:
2024-03-08 04:48:01 -07:00
2023-10-26 00:54:14 -06:00
```javascript
source={{ uri: 'ipod-library:///path/to/music.mp3' }}
```
Note: Using this feature adding an entry for NSAppleMusicUsageDescription to your Info.plist file as described [here](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html)
##### Explicit mimetype for the stream
Provide a member `type` with value (`mpd`/`m3u8`/`ism`) inside the source object.
Sometimes is needed when URL extension does not match with the mimetype that you are expecting, as seen on the next example. (Extension is .ism -smooth streaming- but file served is on format mpd -mpeg dash-)
Example:
2024-03-08 04:48:01 -07:00
2023-10-26 00:54:14 -06:00
```javascript
source={{ uri: 'http://host-serving-a-type-different-than-the-extension.ism/manifest(format=mpd-time-csf)',
type: 'mpd' }}
```
##### Other protocols
The following other types are supported on some platforms, but aren't fully documented yet:
`content://, ms-appx://, ms-appdata://, assets-library://`
2024-07-10 04:17:22 -06:00
#### Using DRM content
2024-09-20 09:46:10 -06:00
<PlatformsList types={['Android', 'iOS', 'visionOS', 'tvOS']} />
2024-07-10 04:17:22 -06:00
To setup DRM please follow [this guide](/component/drm)
Example:
```javascript
{
description: 'WV: Secure SD & HD (cbcs,MP4,H264)',
uri: 'https://storage.googleapis.com/wvmedia/cbcs/h264/tears/tears_aes_cbcs.mpd',
drm: {
type: DRMType.WIDEVINE,
licenseServer:
'https://proxy.uat.widevine.com/proxy?provider=widevine_test',
},
},
```
2023-11-24 04:52:46 -07:00
#### Start playback at a specific point in time
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android', 'iOS']} />
2023-11-24 04:52:46 -07:00
Provide an optional `startPosition` for video. Value is in milliseconds. If the `cropStart` prop is applied, it will be applied from that point forward.
(If it is negative or undefined or null, it is ignored)
2023-10-26 00:54:14 -06:00
#### Playing only a portion of the video (start & end time)
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android', 'iOS']} />
2023-11-24 04:52:46 -07:00
Provide an optional `cropStart` and/or `cropEnd` for the video. Value is in milliseconds. Useful when you want to play only a portion of a large video.
2023-10-26 00:54:14 -06:00
Example
2024-03-08 04:48:01 -07:00
2023-10-26 00:54:14 -06:00
```javascript
2023-11-24 04:52:46 -07:00
source={{ uri: 'https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8', cropStart: 36012, cropEnd: 48500 }}
2023-10-26 00:54:14 -06:00
2023-11-24 04:52:46 -07:00
source={{ uri: 'https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8', cropStart: 36012 }}
2023-10-26 00:54:14 -06:00
2023-11-24 04:52:46 -07:00
source={{ uri: 'https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8', cropEnd: 48500 }}
2023-10-26 00:54:14 -06:00
```
#### Overriding the metadata of a source
2024-06-07 06:06:46 -06:00
<PlatformsList types={['Android', 'iOS', 'tvOS']} />
2024-03-08 04:48:01 -07:00
2024-05-07 04:30:57 -06:00
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.
2023-10-26 00:54:14 -06:00
Example:
```javascript
2024-03-08 04:48:01 -07:00
source={{
uri: 'https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8',
2024-05-07 04:30:57 -06:00
metadata: {
title: 'Custom Title',
subtitle: 'Custom Subtitle',
artist: 'Custom Artist',
description: 'Custom Description',
imageUri: 'https://pbs.twimg.com/profile_images/1498641868397191170/6qW2XkuI_400x400.png'
}
2023-10-26 00:54:14 -06:00
}}
```
2024-10-10 15:53:39 -06:00
### `ad`
<PlatformsList types={['Android', 'iOS']} />
Sets the ad configuration.
Example:
```
ad: {
adTagUrl="https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpremidpostoptimizedpodbumper&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&cmsid=496&vid=short_onecue&correlator="
adLanguage="fr"
}
```
See: [./ads.md] for more informations
Note: You need enable IMA SDK in gradle or pod file - [enable client side ads insertion](/installation)
2024-09-14 11:53:54 -06:00
#### `contentStartTime`
<PlatformsList types={['Android']} />
The start time in ms for SSAI content. This determines at what time to load the video info like resolutions. Use this only when you have SSAI stream where ads resolution is not the same as content resolution.
Note: This feature only works on DASH streams
2024-06-07 06:06:46 -06:00
#### `textTracksAllowChunklessPreparation`
<PlatformsList types={['Android']} />
AllowChunklessPreparation for hls media source.
see: [disabling-chunkless](https://developer.android.com/media/media3/exoplayer/hls?#disabling-chunkless) in android documentation.
Default value: true.
```javascript
source={{
uri: 'https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8',
textTracksAllowChunklessPreparation: false,
}}
```
2024-09-13 02:50:33 -06:00
#### `textTracks`
<PlatformsList types={['Android', 'iOS', 'visionOS']} />
Load one or more "sidecar" text tracks. This takes an array of objects representing each track. Each object should have the format:
> ⚠️ This feature does not work with HLS playlists (e.g m3u8) on iOS
2024-10-05 03:20:54 -06:00
| Property | Description |
|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| title | Descriptive name for the track |
| language | 2 letter [ISO 639-1 code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) representing the language |
| type | Mime type of the track _ TextTrackType.SUBRIP - SubRip (.srt) _ TextTrackType.TTML - TTML (.ttml) \* TextTrackType.VTT - WebVTT (.vtt)iOS only supports VTT, Android supports all 3 |
| uri | URL for the text track. Currently, only tracks hosted on a webserver are supported |
2024-09-13 02:50:33 -06:00
On iOS, sidecar text tracks are only supported for individual files, not HLS playlists. For HLS, you should include the text tracks as part of the playlist.
Note: Due to iOS limitations, sidecar text tracks are not compatible with Airplay. If textTracks are specified, AirPlay support will be automatically disabled.
Example:
```javascript
import { TextTrackType }, Video from 'react-native-video';
textTracks={[
{
title: "English CC",
language: "en",
type: TextTrackType.VTT, // "text/vtt"
uri: "https://bitdash-a.akamaihd.net/content/sintel/subtitles/subtitles_en.vtt"
},
{
title: "Spanish Subtitles",
language: "es",
2024-10-05 03:20:54 -06:00
type: TextTrackType.SUBRIP, // "application/x-subrip"
2024-09-13 02:50:33 -06:00
uri: "https://durian.blender.org/wp-content/content/subtitles/sintel_es.srt"
}
]}
```
2023-10-26 00:54:14 -06:00
### `subtitleStyle`
2024-09-02 08:13:06 -06:00
<PlatformsList types={['Android', 'iOS']} />
| Property | Platform | Description | Platforms |
| ------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ |
| fontSize | Android | Adjust the font size of the subtitles. Default: font size of the device | Android |
| paddingTop | Android | Adjust the top padding of the subtitles. Default: 0 | Android |
| paddingBottom | Android | Adjust the bottom padding of the subtitles. Default: 0 | Android |
| paddingLeft | Android | Adjust the left padding of the subtitles. Default: 0 | Android |
| paddingRight | Android | Adjust the right padding of the subtitles. Default: 0 | Android |
| opacity | Android, iOS | Adjust the visibility of subtitles with 0 hiding and 1 fully showing them. Android supports float values between 0 and 1 for varying opacity levels, whereas iOS supports only 0 or 1. Default: 1. | Android, iOS |
| subtitlesFollowVideo | Android | Boolean to adjust position of subtitles. Default: true |
2023-10-26 00:54:14 -06:00
Example:
```javascript
2024-03-14 04:29:50 -06:00
subtitleStyle={{ paddingBottom: 50, fontSize: 20, opacity: 0 }}
2023-10-26 00:54:14 -06:00
```
2024-09-02 08:13:06 -06:00
Note for `subtitlesFollowVideo`
`subtitlesFollowVideo` helps to determine how the subtitles are positionned.
To understand this prop you need to understand how views management works.
The main View style passed to react native video is the position reserved to display the video component.
It may not match exactly the real video size.
For exemple, you can pass a 4:3 video view and render a 16:9 video inside.
So there is a second view, the video view.
Subtitles are managed in a third view.
First react-native-video resize the video to keep aspect ratio (depending on `resizeMode` property) and put it in main view.
* When putting subtitlesFollowVideo to true, the subtitle view will be adapt to the video view.
It means that if the video is displayed out of screen, the subtitles may also be displayed out of screen.
* When putting subtitlesFollowVideo to false, the subtitle view will keep adapting to the main view.
It means that if the video is displayed out of screen, the subtitles may also be displayed out of screen.
This prop can be changed on runtime.
2023-10-26 00:54:14 -06:00
### `textTracks`
2024-03-08 04:48:01 -07:00
2024-09-13 02:50:33 -06:00
> [!WARNING]
> deprecated, use source.textTracks instead. changing text tracks will restart playback
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android', 'iOS', 'visionOS']} />
2023-10-26 00:54:14 -06:00
Load one or more "sidecar" text tracks. This takes an array of objects representing each track. Each object should have the format:
2024-03-08 04:48:01 -07:00
2023-11-17 00:19:39 -07:00
> ⚠️ This feature does not work with HLS playlists (e.g m3u8) on iOS
2023-10-26 00:54:14 -06:00
2024-10-05 03:20:54 -06:00
| Property | Description |
|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| title | Descriptive name for the track |
| language | 2 letter [ISO 639-1 code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) representing the language |
| type | Mime type of the track _ TextTrackType.SUBRIP - SubRip (.srt) _ TextTrackType.TTML - TTML (.ttml) \* TextTrackType.VTT - WebVTT (.vtt)iOS only supports VTT, Android supports all 3 |
| uri | URL for the text track. Currently, only tracks hosted on a webserver are supported |
2023-10-26 00:54:14 -06:00
On iOS, sidecar text tracks are only supported for individual files, not HLS playlists. For HLS, you should include the text tracks as part of the playlist.
Note: Due to iOS limitations, sidecar text tracks are not compatible with Airplay. If textTracks are specified, AirPlay support will be automatically disabled.
Example:
2024-03-08 04:48:01 -07:00
2023-10-26 00:54:14 -06:00
```javascript
import { TextTrackType }, Video from 'react-native-video';
textTracks={[
{
title: "English CC",
language: "en",
type: TextTrackType.VTT, // "text/vtt"
uri: "https://bitdash-a.akamaihd.net/content/sintel/subtitles/subtitles_en.vtt"
},
{
title: "Spanish Subtitles",
language: "es",
2024-10-05 03:20:54 -06:00
type: TextTrackType.SUBRIP, // "application/x-subrip"
2023-10-26 00:54:14 -06:00
uri: "https://durian.blender.org/wp-content/content/subtitles/sintel_es.srt"
}
]}
```
2024-05-30 04:57:30 -06:00
### `showNotificationControls`
2024-05-07 04:30:57 -06:00
2024-05-22 14:59:32 -06:00
<PlatformsList types={['Android', 'iOS']} />
2024-05-07 04:30:57 -06:00
2024-05-20 04:45:18 -06:00
Controls whether to show media controls in the notification area.
2024-05-07 04:30:57 -06:00
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.
2024-05-28 01:31:00 -06:00
On android this will also allow for external controls, Google Assistant session and other benefits of MediaSession.
2024-05-07 04:30:57 -06:00
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>
```
2024-05-04 06:36:39 -06:00
### `useSecureView`
2023-10-26 00:54:14 -06:00
2024-06-27 03:58:06 -06:00
> [!WARNING]
> deprecated, use viewType instead
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android']} />
2023-10-26 00:54:14 -06:00
2024-05-04 06:36:39 -06:00
Force the output to a SurfaceView and enables the secure surface.
This will override useTextureView flag.
SurfaceView is is the only one that can be labeled as secure.
- **true** - Use security
- **false (default)** - Do not use security
2023-10-26 00:54:14 -06:00
2024-06-27 03:58:06 -06:00
2023-10-26 00:54:14 -06:00
### `useTextureView`
2024-03-08 04:48:01 -07:00
2024-06-27 03:58:06 -06:00
> [!WARNING]
> deprecated, use viewType instead
2024-03-08 04:48:01 -07:00
<PlatformsList types={['Android']} />
2023-10-26 00:54:14 -06:00
Controls whether to output to a TextureView or SurfaceView.
SurfaceView is more efficient and provides better performance but has two limitations:
2024-03-08 04:48:01 -07:00
- It can't be animated, transformed or scaled
- You can't overlay multiple SurfaceViews
2023-10-26 00:54:14 -06:00
2024-03-08 04:48:01 -07:00
useTextureView can only be set at same time you're setting the source.
2023-10-26 00:54:14 -06:00
2024-03-08 04:48:01 -07:00
- **true (default)** - Use a TextureView
- **false** - Use a SurfaceView
2023-10-26 00:54:14 -06:00
2024-06-27 03:58:06 -06:00
### `viewType`
<PlatformsList types={['Android']} />
Allow to explicitly specify view type.
This flag replace `useSecureView` and `useTextureView` fields.
There are 3 available values:
- 'textureView': The video is rendered in a texture view. it allows mapping the view on a texture (useful for 3D).
DRM playback is not supported on textureView, if drm prop is provided, the suface will be transformed to a SurfaceView.
- 'surfaceView' (default): The video is rendered in a surface. take less resources to be rendered.
- 'secureView': The video is rendered in a surface which disallow taking screenshot of the video
2023-10-26 00:54:14 -06:00
### `volume`
2024-03-08 04:48:01 -07:00
<PlatformsList types={['All']} />
2023-10-26 00:54:14 -06:00
Adjust the volume.
2024-03-08 04:48:01 -07:00
- **1.0 (default)** - Play at full volume
- **0.0** - Mute the audio
- **Other values** - Reduce volume
2024-08-22 02:47:51 -06:00
### `cmcd`
<PlatformsList types={['Android']} />
Configure CMCD (Common Media Client Data) parameters. CMCD is a standard for conveying client-side metrics and capabilities to servers, which can help improve streaming quality and performance.
For detailed information about CMCD, please refer to the [CTA-5004 Final Specification](https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5004-final.pdf).
- **false (default)** - Don't use CMCD
- **true** - Use default CMCD configuration
- **object** - Use custom CMCD configuration
When providing an object, you can configure the following properties:
| Property | Type | Description |
|----------|-------------------------|----------------------------------------------------|
| `mode` | `CmcdMode` | The mode for sending CMCD data |
| `request` | `CmcdData` | Custom key-value pairs for the request object |
| `session` | `CmcdData` | Custom key-value pairs for the session object |
| `object` | `CmcdData` | Custom key-value pairs for the object metadata |
| `status` | `CmcdData` | Custom key-value pairs for the status information |
Note: The `mode` property defaults to `CmcdMode.MODE_QUERY_PARAMETER` if not specified.
#### `CmcdMode`
CmcdMode is an enum that defines how CMCD data should be sent:
- `CmcdMode.MODE_REQUEST_HEADER` (0) - Send CMCD data in the HTTP request headers.
- `CmcdMode.MODE_QUERY_PARAMETER` (1) - Send CMCD data as query parameters in the URL.
#### `CmcdData`
CmcdData is a type representing custom key-value pairs for CMCD data. It's defined as:
```typescript
type CmcdData = Record<`${string}-${string}`, string | number>;
```
Custom key names MUST include a hyphenated prefix to prevent namespace collisions. It's recommended to use a reverse-DNS syntax for custom prefixes.
Example:
```javascript
<Video
source={{
uri: 'https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8',
cmcd: {
mode: CmcdMode.MODE_QUERY_PARAMETER,
request: {
'com-custom-key': 'custom-value'
},
session: {
sid: 'session-id'
},
object: {
br: '3000',
d: '4000'
},
status: {
rtp: '1200'
}
}
}}
// or other video props
/>
2024-09-04 01:53:30 -06:00
```