Events related to video playback state and progress.onPlaybackStateChange
Called when the player playback state changes.Callback Signature:onPlaybackStateChange: (data: onPlaybackStateChangeData) => void
Event Data:Whether the video is playing.
Whether the video is buffering.
Example:<Video
source={videoSource}
onPlaybackStateChange={(data) => {
console.log('Playing:', data.isPlaying);
console.log('Buffering:', data.isBuffering);
}}
/>
onPlaybackRateChange
Called when the player playback rate changes.Callback Signature:onPlaybackRateChange: (rate: number) => void
Parameters:
rate - The new playback rate (e.g., 1.0 for normal speed, 2.0 for 2x speed)
Example:<Video
source={videoSource}
onPlaybackRateChange={(rate) => {
console.log('Playback rate changed to:', rate);
}}
/>
onProgress
Called when the player progress changes.Callback Signature:onProgress: (data: onProgressData) => void
Event Data:The current time of the video in seconds.
The time that player is able to play with only buffer.
Example:<Video
source={videoSource}
onProgress={(data) => {
console.log('Current time:', data.currentTime);
console.log('Buffer duration:', data.bufferDuration);
}}
/>
onEnd
Called when the video ends.Callback Signature:Example:<Video
source={videoSource}
onEnd={() => {
console.log('Video has ended');
// Navigate to next video or show replay button
}}
/>
onSeek
Called when the player seeks.Callback Signature:onSeek: (seekTime: number) => void
Parameters:
seekTime - The time in seconds that the player seeked to
Example:<Video
source={videoSource}
onSeek={(seekTime) => {
console.log('Seeked to:', seekTime);
}}
/>
Events related to video loading and initialization.onLoadStart
Called when the video starts loading.The loading lifecycle: onLoadStart → initialize the player → onLoad
Callback Signature:onLoadStart: (data: onLoadStartData) => void
Event Data:The type of the source. local for local files, network for network sources.
Example:<Video
source={videoSource}
onLoadStart={(data) => {
console.log('Loading started:', data.sourceType);
}}
/>
onLoad
Called when the video is loaded.The loading lifecycle: onLoadStart → initialize the player → onLoad
Callback Signature:onLoad: (data: onLoadData) => void
Event Data:The current time of the video in seconds.
The duration of the video in seconds. Returns NaN if the duration is unknown.
The width of the video in pixels.
The height of the video in pixels.
The orientation of the video. Possible values: 'portrait', 'landscape', 'portrait-upside-down', 'landscape-left', 'landscape-right', 'square', or 'unknown'.
Example:<Video
source={videoSource}
onLoad={(data) => {
console.log('Video loaded:');
console.log('Duration:', data.duration);
console.log('Dimensions:', data.width, 'x', data.height);
console.log('Orientation:', data.orientation);
}}
/>
onReadyToDisplay
Called when the video is ready to display.Callback Signature:onReadyToDisplay: () => void
Example:<Video
source={videoSource}
onReadyToDisplay={() => {
console.log('Video is ready to display');
// Hide loading spinner
}}
/>
onBuffer
Called when the video is buffering.Callback Signature:onBuffer: (buffering: boolean) => void
Parameters:
buffering - Whether the video is buffering
Example:<Video
source={videoSource}
onBuffer={(buffering) => {
if (buffering) {
console.log('Video is buffering...');
// Show loading indicator
} else {
console.log('Buffering complete');
// Hide loading indicator
}
}}
/>
Events related to audio handling and focus.onAudioBecomingNoisy
Called when the audio becomes noisy.Callback Signature:onAudioBecomingNoisy: () => void
Example:<Video
source={videoSource}
onAudioBecomingNoisy={() => {
console.log('Audio becoming noisy - pausing playback');
// Typically pause the video when headphones are disconnected
}}
/>
onAudioFocusChange
Called when the audio focus changes.Callback Signature:onAudioFocusChange: (hasAudioFocus: boolean) => void
Parameters:
hasAudioFocus - Whether the audio has focus
Example:<Video
source={videoSource}
onAudioFocusChange={(hasAudioFocus) => {
if (hasAudioFocus) {
console.log('Audio focus gained');
} else {
console.log('Audio focus lost');
// Pause or duck audio volume
}
}}
/>
onVolumeChange
Called when the volume of the player changes.Callback Signature:onVolumeChange: (data: onVolumeChangeData) => void
Event Data:The volume of the player (0.0 = 0%, 1.0 = 100%).
Whether the player is muted.
Example:<Video
source={videoSource}
onVolumeChange={(data) => {
console.log('Volume:', data.volume * 100 + '%');
console.log('Muted:', data.muted);
}}
/>
Events related to network bandwidth and streaming quality.onBandwidthUpdate
Called when the bandwidth of the video changes.Callback Signature:onBandwidthUpdate: (data: BandwidthData) => void
Event Data:The bitrate of the video in bits per second.
The width of the video in pixels.
The height of the video in pixels.
Example:<Video
source={videoSource}
onBandwidthUpdate={(data) => {
console.log('Bitrate:', data.bitrate / 1000000 + ' Mbps');
if (data.width && data.height) {
console.log('Quality:', data.width + 'x' + data.height);
}
}}
/>
Events related to subtitles and closed captions.onTrackChange
Called when the selected text track changes.Callback Signature:onTrackChange: (track: TextTrack | null) => void
Parameters:
track - The newly selected text track, or null if no track is selected
TextTrack Structure:Unique identifier for the text track.
Display label for the text track.
Language code (ISO 639-1 or ISO 639-2), e.g., “en”, “es”, “fr”.
Whether this track is currently selected.
Example:<Video
source={videoSource}
onTrackChange={(track) => {
if (track) {
console.log('Subtitle track changed:', track.label);
console.log('Language:', track.language);
} else {
console.log('Subtitles disabled');
}
}}
/>
onTextTrackDataChanged
Called when the text track (currently displayed subtitle) data changes.Callback Signature:onTextTrackDataChanged: (texts: string[]) => void
Parameters:
texts - Array of currently displayed subtitle text strings
Example:<Video
source={videoSource}
onTextTrackDataChanged={(texts) => {
console.log('Current subtitles:', texts.join('\n'));
}}
/>
Called when player receives timed metadata.Callback Signature:onTimedMetadata: (metadata: TimedMetadata) => void
Event Data:metadata
Array<TimedMetadataObject>
The timed metadata of the video.
TimedMetadataObject Structure:
value (string) - The metadata value
identifier (string) - The metadata identifier
Example:<Video
source={videoSource}
onTimedMetadata={(data) => {
data.metadata.forEach((item) => {
console.log(`${item.identifier}: ${item.value}`);
});
}}
/>