fix(ts): onPlaybackRateChangeData was not correctly typed (#3651)

This commit is contained in:
Olivier Bouillet 2024-04-04 14:45:39 +02:00 committed by GitHub
parent 10b100de44
commit 2a858df8bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 4 deletions

View File

@ -36,6 +36,8 @@ import Video, {
OnTextTrackDataChangedData, OnTextTrackDataChangedData,
TextTrackType, TextTrackType,
ISO639_1, ISO639_1,
OnPlaybackStateChangedData,
OnPlaybackRateChangeData,
} from 'react-native-video'; } from 'react-native-video';
import ToggleControl from './ToggleControl'; import ToggleControl from './ToggleControl';
import MultiValueControl, { import MultiValueControl, {
@ -335,6 +337,14 @@ class VideoPlayer extends Component {
this.channelUp(); this.channelUp();
}; };
onPlaybackRateChange = (data: OnPlaybackRateChangeData) => {
console.log('onPlaybackRateChange', data);
}
onPlaybackStateChanged = (data: OnPlaybackStateChangedData) => {
console.log('onPlaybackStateChanged', data);
}
toggleFullscreen() { toggleFullscreen() {
this.setState({fullscreen: !this.state.fullscreen}); this.setState({fullscreen: !this.state.fullscreen});
} }
@ -805,6 +815,8 @@ class VideoPlayer extends Component {
selectedAudioTrack={this.state.selectedAudioTrack} selectedAudioTrack={this.state.selectedAudioTrack}
playInBackground={false} playInBackground={false}
preventsDisplaySleepDuringVideoPlayback={true} preventsDisplaySleepDuringVideoPlayback={true}
onPlaybackRateChange={this.onPlaybackRateChange}
onPlaybackStateChanged={this.onPlaybackStateChanged}
/> />
</TouchableOpacity> </TouchableOpacity>
); );

View File

@ -218,7 +218,7 @@ export type OnVideoTracksData = Readonly<{
}[]; }[];
}>; }>;
export type OnPlaybackData = Readonly<{ export type OnPlaybackRateChangeData = Readonly<{
playbackRate: Float; playbackRate: Float;
}>; }>;
@ -328,7 +328,7 @@ export interface VideoNativeProps extends ViewProps {
onVideoFullscreenPlayerWillDismiss?: DirectEventHandler<{}>; // ios, android onVideoFullscreenPlayerWillDismiss?: DirectEventHandler<{}>; // ios, android
onVideoFullscreenPlayerDidDismiss?: DirectEventHandler<{}>; // ios, android onVideoFullscreenPlayerDidDismiss?: DirectEventHandler<{}>; // ios, android
onReadyForDisplay?: DirectEventHandler<{}>; onReadyForDisplay?: DirectEventHandler<{}>;
onPlaybackRateChange?: DirectEventHandler<OnPlaybackData>; // all onPlaybackRateChange?: DirectEventHandler<OnPlaybackRateChangeData>; // all
onVolumeChange?: DirectEventHandler<OnVolumeChangeData>; // android, ios onVolumeChange?: DirectEventHandler<OnVolumeChangeData>; // android, ios
onVideoExternalPlaybackChange?: DirectEventHandler<OnExternalPlaybackChangeData>; onVideoExternalPlaybackChange?: DirectEventHandler<OnExternalPlaybackChangeData>;
onGetLicense?: DirectEventHandler<OnGetLicenseData>; onGetLicense?: DirectEventHandler<OnGetLicenseData>;

View File

@ -7,7 +7,7 @@ import type {
OnExternalPlaybackChangeData, OnExternalPlaybackChangeData,
OnLoadStartData, OnLoadStartData,
OnPictureInPictureStatusChangedData, OnPictureInPictureStatusChangedData,
OnPlaybackData, OnPlaybackRateChangeData,
OnPlaybackStateChangedData, OnPlaybackStateChangedData,
OnProgressData, OnProgressData,
OnSeekData, OnSeekData,
@ -239,7 +239,7 @@ export interface ReactVideoEvents {
onPictureInPictureStatusChanged?: ( onPictureInPictureStatusChanged?: (
e: OnPictureInPictureStatusChangedData, e: OnPictureInPictureStatusChangedData,
) => void; //iOS ) => void; //iOS
onPlaybackRateChange?: (e: OnPlaybackData) => void; //All onPlaybackRateChange?: (e: OnPlaybackRateChangeData) => void; //All
onVolumeChange?: (e: OnVolumeChangeData) => void; //Android, iOS onVolumeChange?: (e: OnVolumeChangeData) => void; //Android, iOS
onProgress?: (e: OnProgressData) => void; //All onProgress?: (e: OnProgressData) => void; //All
onReadyForDisplay?: () => void; //Android, iOS onReadyForDisplay?: () => void; //Android, iOS