This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Expo 视频 (expo-video)
提供 API 以实现应用中的视频播放的库。
expo-video 是一个跨平台、高性能的视频组件,适用于 React Native 和 Expo,并支持 Web。
已知问题 Android
🌐 Known issues
当两个 VideoView 组件重叠并且设置了 contentFit 属性为 cover 时,其中一个视频可能会显示在边界之外。这是一个 已知的上游问题。为了解决此问题,请使用 surfaceType 属性并将其设置为 textureView。
🌐 When two VideoView components are overlapping and have the contentFit prop set to cover, one of the videos may be displayed out of bounds. This is a known upstream issue. To work around this issue, use the surfaceType prop and set it to textureView.
安装
🌐 Installation
If you are installing this in an existing React Native app, make sure to install expo in your project.
应用配置中的配置
🌐 Configuration in app config
如果你在项目中使用配置插件(连续原生生成 (CNG)),可以使用其内置的 配置插件 来配置 expo-video。该插件允许你配置无法在运行时设置并且需要构建新的应用二进制文件才能生效的各种属性。如果你的应用不使用 CNG,那么你需要手动配置该库。
🌐 You can configure expo-video using its built-in config plugin if you use config plugins in your project (Continuous Native Generation (CNG)). The plugin allows you to configure various properties that cannot be set at runtime and require building a new app binary to take effect. If your app does not use CNG, then you'll need to manually configure the library.
Example app.json with config plugin
Configurable properties
用法
🌐 Usage
这是一个带有播放和暂停按钮的视频的简单示例。
🌐 Here's a simple example of a video with a play and pause button.
推荐资源
🌐 Receiving events
[VideoPlayer](#videoplayer) 的属性变化不会更新 React 状态。因此,要显示 VideoPlayer 当前状态的信息,就需要监听它发出的 事件。
事件系统基于 EventEmitter 类和 expo 包里的 hooks。监听事件有几种方法:
🌐 The changes in properties of the VideoPlayer do not update the React state. Therefore, to display the information about the current state of the VideoPlayer, it is necessary to listen to the events it emits.
The event system is based on the EventEmitter class and hooks from the expo package. There are a few ways to listen to events:
useEvent 钩
🌐 useEvent hook
创建一个监听器,它将返回一个可用于组件的有状态值。当组件卸载时,它也会自动清理。
🌐 Creates a listener that will return a stateful value that can be used in a component. It also cleans up automatically when the component unmounts.
useEventListener 钩
🌐 useEventListener hook
基于 Player.addListener 和 Player.removeListener 方法创建,生成一个具有自动清理功能的事件监听器。
🌐 Built around the Player.addListener and Player.removeListener methods, creates an event listener with automatic cleanup.
Player.addListener 方法
🌐 Player.addListener method
监听事件的最灵活方式,但需要手动清理和更多样板代码。
🌐 Most flexible way to listen to events, but requires manual cleanup and more boilerplate code.
从资源目录播放本地媒体
🌐 Playing local media from the assets directory
expo-video 支持播放使用 require 函数加载的本地媒体。你可以直接将结果用作来源,或者如果你还想配置其他属性,可以将其分配给 VideoSource 的 assetId 参数。
从媒体库播放媒体
🌐 Playing media from the media library
expo-video 支持使用 expo-media-library/legacy 或任何具有适当权限的有效 PHAsset URI 播放从用户媒体库中选取的视频。
要从媒体库播放视频,你应该使用 MediaLibrary.getAssetsAsync() 获取一个 Asset 对象,并将其 uri 属性用作视频源的 uri。在播放之前,请确保使用 MediaLibrary.requestPermissionsAsync() 请求必要的权限。
🌐 To play a video from the media library, you should obtain an Asset object with MediaLibrary.getAssetsAsync() and use its uri property as the uri of the video source.
Before playing, make sure to request the necessary permissions using MediaLibrary.requestPermissionsAsync().
在 iOS 上,请确保不要使用资源信息的 localUri 属性,因为它不包含读取该资源所需的权限。
🌐 On iOS make sure not to use the localUri property of the asset info, as it does not contain the necessary permissions to read the asset.
预加载视频
🌐 Preloading videos
在播放另一个视频的同时,可以在显示视频之前先加载它。这可以实现后续视频之间更快的切换,并提供更好的用户体验。
🌐 While another video is playing, a video can be loaded before showing it in the view. This allows for quicker transitions between subsequent videos and a better user experience.
要预加载视频,你必须创建一个带有视频源的 VideoPlayer。即使播放器未连接到 VideoView,它也会填充缓冲区。一旦连接到 VideoView,它就可以无缓冲地开始播放。
🌐 To preload a video, you have to create a VideoPlayer with a video source. Even when the player is not connected to a VideoView, it will fill the buffers. Once it is connected to the VideoView, it will be able to start playing without buffering.
在某些情况下,在屏幕生命周期的后期预加载视频是有益的。在这种情况下,应创建一个带有 null 源的 VideoPlayer。要开始预加载,请使用 replace() 函数将播放器源替换为视频源。
🌐 In some cases, it is beneficial to preload a video later in the screen lifecycle. In that case, a VideoPlayer with a null source should be created. To start preloading, replace the player source with a video source using the replace() function.
以下是如何预加载视频的示例:
🌐 Here is an example of how to preload a video:
不使用其他 EAS 服务
🌐 Using the VideoPlayer directly
在大多数情况下,应该使用 useVideoPlayer 钩子来创建 VideoPlayer 实例。它会管理播放器的生命周期,并确保在组件卸载时正确释放。不过,在一些高级用例中,可能需要创建一个 VideoPlayer,它在组件卸载时不会自动销毁。
在这种情况下,可以使用 createVideoPlayer 函数来创建 VideoPlayer。你需要注意这种做法带来的风险,因为当播放器不再需要时,你有责任调用 release() 方法。如果处理不当,这种做法可能会导致内存泄漏。
🌐 In most cases, the useVideoPlayer hook should be used to create a VideoPlayer instance. It manages the player's lifecycle and ensures that it is properly disposed of when the component is unmounted. However, in some advanced use cases, it might be necessary to create a VideoPlayer that does not get automatically destroyed when the component is unmounted.
In those cases, the VideoPlayer can be created using the createVideoPlayer function. You need be aware of the risks that come with this approach, as it is your responsibility to call the release() method when the player is no longer needed. If not handled properly, this approach may lead to memory leaks.
警告 在 Android 上,由于平台限制,同时使用相同的
VideoPlayer实例挂载多个VideoView组件将无法工作。
缓存视频
🌐 Caching videos
如果你的应用经常重复播放同一视频,可以利用缓存来减少网络使用并提升用户体验,尽管这会增加设备存储的使用。expo-video 支持在 Android 和 iOS 平台上进行视频缓存。可以通过将 VideoSource 对象的 useCaching 属性设置为 true 来启用此功能。
🌐 If your app frequently replays the same video, caching can be utilized to minimize network usage and enhance user experience, albeit at the cost of increased device storage usage. expo-video supports video caching on Android and iOS platforms. This feature can be activated by setting the useCaching property of a VideoSource object to true.
缓存是持久性的,一旦超过首选大小,将按最少使用原则进行清除。此外,由于存储空间不足,系统可能会清除缓存,因此不建议依赖缓存来存储关键数据。
🌐 The cache is persistent and will be cleared on a least-recently-used basis once the preferred size is exceeded. Furthermore, the system can clear the cache due to low storage availability, so it's not advisable to depend on the cache to store critical data.
缓存功能可以在离线状态下使用。如果视频的部分或全部已被缓存,即使设备处于离线状态,也可以从缓存中播放,直到缓存数据耗尽。
🌐 The cache functions offline. If a portion or the entirety of a video is cached, it can be played from the cache even when the device is offline until the cached data is exhausted.
由于平台限制,在 iOS 上无法将缓存用于 HLS 视频源。在 Android 和 iOS 上不支持缓存 DRM 保护的视频。
管理缓存
🌐 Managing the cache
- 首选的缓存大小(以字节为单位)可以使用
setVideoCacheSizeAsync函数定义。默认的缓存大小为 1GB。 [getCurrentVideoCacheSize](#videogetcurrentvideocachesize)可用于获取缓存当前占用的存储字节数。- 所有缓存的视频都可以使用
clearVideoCacheAsync功能清除。
拦截原生资源加载
🌐 Intercepting native asset loading
这是一个面向高级用户的原生 expo-video 功能。展开以了解更多。
介绍
🌐 Introduction
expo-video 在 iOS 上包括一个名为 VideoAssetTransportProvider 的原生扩展点。它允许你拦截特定的视频源,自定义底层 AVURLAsset 的创建方式,并重写它加载数据的方式。
当某个源无法被 AVKit 直接处理并且需要本地预处理时,这非常有用。例如,提供者可以重写 URL、附加自定义的 AVAssetResourceLoaderDelegate、启动本地代理服务器,或在播放开始之前将一种流格式转换为另一种。
🌐 This is useful when a source cannot be handled by AVKit directly and needs native preprocessing. For example, a provider can rewrite a URL, attach a custom AVAssetResourceLoaderDelegate, start a local proxy server, or transform one streaming format into another before playback begins.
提供者在模块启动时注册到 VideoAssetTransportRegistry。当 expo-video 加载一个源时,它会创建一个 VideoAssetSourceDescriptor 并按优先顺序询问注册的提供者他们是否想处理它。第一个返回 VideoAssetLoadPlan 的提供者将被使用。
🌐 Providers are registered in the VideoAssetTransportRegistry at module startup. When expo-video loads a source, it creates a VideoAssetSourceDescriptor and asks registered providers, in priority order, whether they want to handle it. The first provider that returns a VideoAssetLoadPlan is used.
此 API 适用于高级原生集成。它需要自定义原生模块,因此在 Expo Go 中不可用。请使用开发版构建。
🌐 This API is intended for advanced native integrations. It requires a custom native module, so it is not available in Expo Go. Use a development build instead.
可自定义属性
🌐 Customizable properties
主要的自定义点是 VideoAssetTransportProvider 上的字段以及它返回的 VideoAssetLoadPlan 上的字段。
🌐 The main customization points are the fields on VideoAssetTransportProvider and the fields on the VideoAssetLoadPlan it returns.
VideoAssetTransportProvider 让你可以控制以下属性:
VideoAssetLoadPlan 允许你通过以下属性控制 expo-video 如何构建和管理资源:
实现与使用
🌐 Implementation and usage
一个典型的设置如下:
🌐 A typical setup looks as follows:
- 使用
create-expo-module创建一个 Expo 模块。 - 添加一个符合
VideoAssetTransportProvider的类。 - 在模块的
OnCreate块中注册提供程序。 - 构建应用,以便将本地模块编译到你的项目中。
如果你只在一个应用中需要提供者,请使用 本地 Expo 模块 流程。
🌐 If you only need the provider in a single app, use the local Expo module flow.
如果你想在多个应用中重复使用该提供者,请改用独立 Expo 模块流程。
🌐 If you want to reuse the provider across multiple apps, use the standalone Expo module flow instead.
基本用法示例
🌐 Basic usage example
- 定义提供者和加载计划。创建模块后,添加一个符合
VideoAssetTransportProvider的类。在makeLoadPlan(for:)中,检查VideoAssetSourceDescriptor并为不想处理的源返回nil。
import ExpoVideo final class ExampleVideoTransportProvider: VideoAssetTransportProvider { static let providerIdentifier = "com.example.video-transport" let identifier = Self.providerIdentifier let priority = 500 func makeLoadPlan(for source: VideoAssetSourceDescriptor) -> VideoAssetLoadPlan? { guard source.contentTypeHint == .dash, source.url.pathExtension == "mpd" else { return nil } let transformedURL = URL(string: "http://127.0.0.1:8080/master.m3u8")! return VideoAssetLoadPlan( assetURL: transformedURL, reportedContentTypeHint: .hls ) } }
- 要注册提供者,推荐注册提供者的位置是 Expo 模块的
OnCreate块。这确保在视频开始加载之前提供者可用。
import ExpoModulesCore import ExpoVideo public final class CustomVideoTransportModule: Module { public func definition() -> ModuleDefinition { Name("CustomVideoTransport") OnCreate { VideoAssetTransportRegistry.registerProvider(ExampleVideoTransportProvider()) } OnDestroy { VideoAssetTransportRegistry.unregisterProvider( withId: ExampleVideoTransportProvider.providerIdentifier ) } } }
完整示例
🌐 Complete examples
你可以使用以下完整示例来更好地掌握如何使用此 API。
🌐 You can use the following complete examples for a better grasp of how to use this API.
- 基础 DASH 支持提供者 - Bare Expo 中的一个本地模块,为 iOS 上的
expo-video提供有限的 DASH 支持。 expo-videoiOS 缓存 - 内置的缓存提供者实现。
应用接口
🌐 API
import { VideoView, useVideoPlayer } from 'expo-video';
Components
Type: React.PureComponent<VideoViewProps>
booleanDetermines whether the player allows Picture in Picture (PiP) mode.
Note: The
supportsPictureInPictureproperty of the config plugin has to be configured for the PiP to work.
boolean • Default: trueSpecifies whether to perform video frame analysis (Live Text in videos). Check official Apple documentation for more details.
ButtonOptionsConfiguration for controlling the visibility of player control buttons.
VideoContentFit • Default: 'contain'Describes how the video should be scaled to fit in the container.
Options are 'contain', 'cover', and 'fill'.
{
dx: number,
dy: number
}Determines the position offset of the video inside the container.
string • Default: undefinedDetermines the cross origin policy used by the underlying native view on web.
If undefined (default), does not use CORS at all. If set to 'anonymous', the video will be loaded with CORS enabled.
Note that some videos may not play if CORS is enabled, depending on the CDN settings.
If you encounter issues, consider adjusting the crossOrigin property.
Acceptable values are: 'anonymous' | 'use-credentials'
FullscreenOptionsDetermines the fullscreen mode options.
boolean • Default: trueDetermines whether native controls should be displayed or not.
Note: Due to platform limitations, the native controls are always enabled in fullscreen mode.
() => voidA callback to call after the mounted VideoPlayer has rendered the first frame into the VideoView.
This event can be used to hide any cover images that conceal the initial loading of the player.
Note: This event may also be called during playback when the current video track changes (for example when the player switches video quality).
() => voidA callback to call after the video player enters fullscreen mode.
() => voidA callback to call after the video player exits fullscreen mode.
() => voidA callback to call after the video player enters Picture in Picture (PiP) mode.
() => voidA callback to call after the video player exits Picture in Picture (PiP) mode.
unionA video player instance. Use useVideoPlayer() hook to create one.
Acceptable values are: VideoPlayer | null
booleanDetermines whether a video should be played "inline", that is, within the element's playback area.
boolean • Default: falseDetermines whether the player allows the user to skip media content.
boolean • Default: trueDetermines whether the timecodes should be displayed or not.
boolean • Default: falseDetermines whether the player should start Picture in Picture (PiP) automatically when the app is in the background.
Note: Only one player can be in Picture in Picture (PiP) mode at a time.
Note: The
supportsPictureInPictureproperty of the config plugin has to be configured for the PiP to work.
SurfaceType • Default: 'surfaceView'Determines the type of the surface used to render the video.
This prop should not be changed at runtime.
boolean • Default: falseUse Audio Nodes for sound playback. When the same player is playing in multiple video views the audio won't increase in volume as the number of players increases.
Note: This property is experimental, when enabled it is known to break audio for some sources. Do not change this property at runtime.
boolean • Default: falseDetermines whether the player should use the default ExoPlayer shutter that covers the VideoView before the first video frame is rendered.
Setting this property to false makes the Android behavior the same as iOS.
Type: React.Element<VideoAirPlayButtonProps>
A view displaying the AVRoutePickerView. Shows a button, when pressed, an AirPlay device picker shows up, allowing users to stream the currently playing video
to any available AirPlay sink.
When using this view, make sure that the
allowsExternalPlaybackplayer property is set totrue.
ColorValue • Default: undefinedThe color of the button icon while AirPlay sharing is active.
() => voidA callback called when the AirPlay route selection popup is about to show.
() => voidA callback called when the AirPlay route selection popup has disappeared.
boolean • Default: trueDetermines whether the AirPlay device selection popup should show video outputs first.
ColorValue • Default: undefinedThe color of the button icon while AirPlay sharing is not active.
Component methods
Enters fullscreen mode.
Promise<void>Exits fullscreen mode.
Note: On Android the JS runtime is paused when the
VideoViewis in fullscreen mode. Because of thisexitFullscreenwill only work when called from a native listener - see the example below.
Promise<void>Example
const ref = useRef<VideoView>() const player = useVideoPlayer(source) // This will work on all platforms useEventListener(player, 'playToEnd', () => { ref.current?.exitFullscreen(); }); // This will not work on Android const enterAndExit = useCallback(() => { setTimeout(() => { ref.current?.exitFullscreen() }, 5000) ref.current?.enterFullscreen() },[])
Enters Picture in Picture (PiP) mode. Throws an exception if the device does not support PiP.
Note: Only one player can be in Picture in Picture (PiP) mode at a time.
Note: The
supportsPictureInPictureproperty of the config plugin has to be configured for the PiP to work.
Promise<void>Exits Picture in Picture (PiP) mode.
Promise<void>Hooks
Creates a VideoPlayer, which will be automatically cleaned up when the component is unmounted.
VideoPlayerClasses
Type: Class extends SharedObject<VideoPlayerEvents>
A class that represents an instance of the video player.
VideoPlayer Properties
boolean • Default: trueDetermines whether the player should allow external playback.
AudioMixingMode • Default: 'auto'Determines how the player will interact with other audio playing in the system.
union • Default: nullSpecifies the audio track currently played by the player. null when no audio is played.
Acceptable values are: AudioTrack | null
AudioTrack[]An array of audio tracks available for the current video.
SubtitleTrack[]An array of subtitle tracks available for the current video.
VideoTrack[]An array of video tracks available for the current video.
On iOS, when using a HLS source, make sure that the uri contains
.m3u8extension or that thecontentTypeproperty of theVideoSourcehas been set to'hls'. Otherwise, the video tracks will not be available.
numberFloat value indicating how far the player has buffered the video in seconds.
This value is 0 when the player has not buffered up to the current playback time. When it's impossible to determine the buffer state (for example, when the player isn't playing any media), this value is -1.
BufferOptionsSpecifies buffer options which will be used by the player when buffering the video.
You should provide a
BufferOptionsobject when setting this property. Setting individual buffer properties is not supported.
unionThe exact timestamp when the currently displayed video frame was sent from the server,
based on the EXT-X-PROGRAM-DATE-TIME tag in the livestream metadata.
If this metadata is missing, this property will return null.
Acceptable values are: number | null
unionFloat value indicating the latency of the live stream in seconds.
If a livestream doesn't have the required metadata, this will return null.
Acceptable values are: number | null
numberFloat value indicating the current playback time in seconds.
If the player is not yet playing, this value indicates the time position
at which playback will begin once the play() method is called.
Setting currentTime to a new value seeks the player to the given time.
Check out the seekTolerance property to configure the seeking precision.
numberFloat value indicating the duration of the current video in seconds.
booleanIndicates whether the player is currently playing back the media to an external device via AirPlay.
booleanBoolean value indicating whether the player is currently playing a live stream.
boolean • Default: trueBoolean indicating if the player should keep the screen on while playing.
On Android, this property has an effect only when a
VideoViewis visible. If you want to keep the screen awake at all times useexpo-keep-awake.
boolean • Default: falseDetermines whether the player should automatically replay after reaching the end of the video.
boolean • Default: falseBoolean value whether the player is currently muted.
Setting this property to true/false will mute/unmute the player.
number • Default: 1.0Float value between 0 and 16.0 indicating the current playback speed of the player.
booleanBoolean value whether the player is currently playing.
Use
playandpausemethods to control the playback.
boolean • Default: trueBoolean value indicating if the player should correct audio pitch when the playback speed changes.
ScrubbingModeOptionsDetermines whether the scrubbing mode is enabled and what scrubbing optimizations should be enabled.
See
SeekToleranceto set the seeking tolerance, which can also affect the scrubbing performance.
SeekToleranceDetermines the time that the actual position seeked to may precede or exceed the requested seek position.
This property affects the precision of setting the currentTime property and the seekBy method, and on Android, it also affects the accuracy of the scrubber from the default native controls.
By default, the player seeks to the exact requested time.
If you are trying to optimize for scrubbing (many frequent seeks), also see
ScrubbingModeOptions.
boolean • Default: falseBoolean value determining whether the player should show the now playing notification.
Note: On Android,
supportsBackgroundPlaybackproperty of the config plugin has to betruefor the now playing notification to work.
VideoPlayerStatusIndicates the current status of the player.
boolean • Default: falseDetermines whether the player should continue playing after the app enters the background.
Note: The
supportsBackgroundPlaybackproperty of the config plugin has to betruefor the background playback to work.
union • Default: nullSpecifies the subtitle track which is currently displayed by the player. null when no subtitles are displayed.
To ensure a valid subtitle track, always assign one of the subtitle tracks from the
availableSubtitleTracksarray.
Acceptable values are: SubtitleTrack | null
number • Default: 0Float value indicating the interval in seconds at which the player will emit the timeUpdate event.
When the value is equal to 0, the event will not be emitted.
union • Default: nullSpecifies the video track currently played by the player. null when no video is displayed.
Acceptable values are: VideoTrack | null
VideoPlayer Methods
Generates thumbnails from the currently played asset. The thumbnails are references to native images,
thus they can be used as a source of the Image component from expo-image.
Promise<VideoThumbnail[]>Replaces the current source with a new one.
On iOS, this method loads the asset data synchronously on the UI thread and can block it for extended periods of time. Use
replaceAsyncto load the asset asynchronously and avoid UI lags.
This method will be deprecated in the future.
voidReplaces the current source with a new one, while offloading loading of the asset to a different thread.
On Android and Web, this method is equivalent to
replace.
Promise<void>Seeks the playback by the given number of seconds. The time to which the player seeks may differ from the specified requested time for efficiency,
depending on the encoding and what is currently buffered by the player. Use this function to implement playback controls that seek by specific amount of time,
in which case, the actual time usually does not have to be precise. For frame accurate seeking, use the currentTime property.
voidType: Class extends SharedRef<'image'>
Represents a video thumbnail that references a native image.
Instances of this class can be passed as a source to the Image component from expo-image.
VideoThumbnail Properties
Methods
Clears all video cache.
This function can be called only if there are no existing
VideoPlayerinstances.
Promise<void>A promise that fulfills after the cache has been cleaned.
Creates a direct instance of VideoPlayer that doesn't release automatically.
For most use cases you should use the
useVideoPlayerhook instead. See the Using the VideoPlayer Directly section for more details.
VideoPlayerReturns the space currently occupied by the video cache in bytes.
numberReturns whether the current device supports Picture in Picture (PiP) mode.
booleanA boolean which is true if the device supports PiP mode, and false otherwise.
Sets desired video cache size in bytes. The default video cache size is 1GB. Value set by this function is persistent. The cache size is not guaranteed to be exact and the actual cache size may be slightly larger. The cache is evicted on a least-recently-used basis.
This function can be called only if there are no existing
VideoPlayerinstances.
Promise<void>A promise that fulfills after the cache size has been set.
Types
Literal type: string
Specifies the audio mode that the player should use. Audio mode is set on per-app basis, if there are multiple players playing and
have different a AudioMode specified, the highest priority mode will be used. Priority order: 'doNotMix' > 'auto' > 'duckOthers' > 'mixWithOthers'.
mixWithOthers: The player will mix its audio output with other apps.duckOthers: The player will lower the volume of other apps if any of the active players is outputting audio.auto: The player will allow other apps to keep playing audio only when it is muted. On iOS it will always interrupt other apps whenshowNowPlayingNotificationistruedue to system requirements.doNotMix: The player will pause playback in other apps, even when it's muted.
On iOS, the Now Playing notification is dependent on the audio mode. If the audio mode is different from
doNotMixorautothis feature will not work.
Acceptable values are: 'mixWithOthers' | 'duckOthers' | 'auto' | 'doNotMix'
Specifies buffer options which will be used by the player when buffering the video.
Configuration for controlling the visibility of player control buttons.
The fullscreen button should be controlled with
fullscreenOptions.enable.
Literal type: string
Specifies the content type of the source.
auto: The player will automatically determine the content type of the video.progressive: The player will use progressive download content type. This is the defaultContentTypewhen the uri does not contain an extension.hls: The player will use HLS content type.dash: The player will use DASH content type (Android-only).smoothStreaming: The player will use SmoothStreaming content type (Android-only).
Default:`auto`
Acceptable values are: 'auto' | 'progressive' | 'hls' | 'dash' | 'smoothStreaming'
Specifies DRM options which will be used by the player while loading the video.
Literal type: string
Specifies which type of DRM to use:
- Android supports ClearKey, PlayReady and Widevine.
- iOS supports FairPlay.
Acceptable values are: 'clearkey' | 'fairplay' | 'playready' | 'widevine'
Options to apply to the player builder before the native constructor is invoked
Contains information about any errors that the player encountered during the playback
Determines the time that the actual position seeked to may precede or exceed the requested seek position.
Larger tolerance will usually result in faster seeking.
This property affects the precision of setting the currentTime property and the seekBy method, and on Android, it also affects the accuracy of the scrubber from the default native controls.
If you are trying to optimize for scrubbing (many frequent seeks), also see
ScrubbingModeOptions.
Data delivered with the sourceLoad event, contains information about the video source that has finished loading.
Literal type: string
Describes the type of the surface used to render the video.
surfaceView: Uses theSurfaceViewto render the video. This value should be used in the majority of cases. Provides significantly lower power consumption, better performance, and more features.textureView: Uses theTextureViewto render the video. Should be used in cases where the SurfaceView is not supported or causes issues (for example, overlapping video views).
You can learn more about surface types in the official ExoPlayer documentation.
Acceptable values are: 'textureView' | 'surfaceView'
Data delivered with the timeUpdate event, contains information about the current playback progress.
Literal type: string
Describes how a video should be scaled to fit in a container.
contain: The video maintains its aspect ratio and fits inside the container, with possible letterboxing/pillarboxing.cover: The video maintains its aspect ratio and covers the entire container, potentially cropping some portions.fill: The video stretches/squeezes to completely fill the container, potentially causing distortion.
Acceptable values are: 'contain' | 'cover' | 'fill'
Contains information that will be displayed in the now playing notification when the video is playing.
Literal type: string
Describes the current status of the player.
idle: The player is not playing or loading any videos.loading: The player is loading video data from the provided sourcereadyToPlay: The player has loaded enough data to start playing or to continue playback.error: The player has encountered an error while loading or playing the video.
Acceptable values are: 'idle' | 'loading' | 'readyToPlay' | 'error'
Literal type: string
Specifies the dynamic range of the video content.
sdr: Standard Dynamic Range video.hlg: Hybrid Log-Gamma - HDR backward-compatible with SDR displayspq: Perceptual Quantizer - Formats like HDR10 and Dolby Vision
Acceptable values are: 'sdr' | 'hlg' | 'pq'
Literal type: union
Acceptable values are: string | number | null | VideoSourceObject
Data delivered with the videoTrackChange event, contains information about the video track which is currently being played.