diff --git a/packages/react-native-video/src/core/hooks/useEvent.ts b/packages/react-native-video/src/core/hooks/useEvent.ts index b7185e93..eefab7d3 100644 --- a/packages/react-native-video/src/core/hooks/useEvent.ts +++ b/packages/react-native-video/src/core/hooks/useEvent.ts @@ -1,6 +1,6 @@ import { useEffect } from 'react'; import type { AllPlayerEvents } from '../types/Events'; -import type { VideoPlayer } from '../VideoPlayer'; +import type { VideoPlayerBase } from '../types/VideoPlayerBase'; /** * Attaches an event listener to a `VideoPlayer` instance for a specified event. @@ -10,7 +10,7 @@ import type { VideoPlayer } from '../VideoPlayer'; * @param callback - The callback for the event */ export const useEvent = ( - player: VideoPlayer, + player: VideoPlayerBase, event: T, callback: AllPlayerEvents[T] ) => { diff --git a/packages/react-native-video/src/core/types/VideoPlayerBase.ts b/packages/react-native-video/src/core/types/VideoPlayerBase.ts index 8167877d..9827d5f8 100644 --- a/packages/react-native-video/src/core/types/VideoPlayerBase.ts +++ b/packages/react-native-video/src/core/types/VideoPlayerBase.ts @@ -1,11 +1,12 @@ +import type { ListenerSubscription } from './EventEmitter'; +import type { AllPlayerEvents } from './Events'; import type { IgnoreSilentSwitchMode } from './IgnoreSilentSwitchMode'; import type { MixAudioMode } from './MixAudioMode'; import type { TextTrack } from './TextTrack'; import type { VideoPlayerSourceBase } from './VideoPlayerSourceBase'; import type { VideoPlayerStatus } from './VideoPlayerStatus'; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -import type { VideoConfig } from './VideoConfig'; +import type { VideoConfig, VideoSource } from './VideoConfig'; export interface VideoPlayerBase { /** @@ -152,7 +153,9 @@ export interface VideoPlayerBase { * @note If you want to clear the source, you can pass null. * see {@link VideoPlayerSourceBase} */ - replaceSourceAsync(source: VideoPlayerSourceBase | null): Promise; + replaceSourceAsync( + source: VideoSource | VideoConfig | VideoPlayerSourceBase | null + ): Promise; /** * Get all available text tracks for the current source. @@ -171,4 +174,19 @@ export interface VideoPlayerBase { * @returns The currently selected text track, or undefined if none is selected */ readonly selectedTrack?: TextTrack; + + /** + * Whether to show notification controls (lock screen / control center). + */ + showNotificationControls: boolean; + + /** + * Releases the player's resources. After calling this, the player is no longer usable. + */ + release(): void; + + addEventListener( + event: Event, + callback: AllPlayerEvents[Event] + ): ListenerSubscription; } diff --git a/packages/react-native-video/src/core/video-view/VideoView.tsx b/packages/react-native-video/src/core/video-view/VideoView.tsx index f486c189..8f6acb6b 100644 --- a/packages/react-native-video/src/core/video-view/VideoView.tsx +++ b/packages/react-native-video/src/core/video-view/VideoView.tsx @@ -38,7 +38,7 @@ const wrapNativeViewManagerFunction = ( }; const updateProps = (manager: VideoViewViewManager, props: VideoViewProps) => { - manager.player = props.player.__getNativePlayer(); + manager.player = (props.player as VideoPlayer).__getNativePlayer(); manager.controls = props.controls ?? false; manager.pictureInPicture = props.pictureInPicture ?? false; manager.autoEnterPictureInPicture = props.autoEnterPictureInPicture ?? false; diff --git a/packages/react-native-video/src/core/video-view/VideoViewProps.ts b/packages/react-native-video/src/core/video-view/VideoViewProps.ts index c8393fe9..b1c93435 100644 --- a/packages/react-native-video/src/core/video-view/VideoViewProps.ts +++ b/packages/react-native-video/src/core/video-view/VideoViewProps.ts @@ -3,13 +3,13 @@ import type { SurfaceType } from '../../spec/nitro/VideoViewViewManager.nitro'; import type { ListenerSubscription } from '../types/EventEmitter'; import type { VideoViewEvents } from '../types/Events'; import type { ResizeMode } from '../types/ResizeMode'; -import type { VideoPlayer } from '../VideoPlayer'; +import type { VideoPlayerBase } from '../types/VideoPlayerBase'; export interface VideoViewProps extends Partial, ViewProps { /** - * The player to play the video - {@link VideoPlayer} + * The player to play the video */ - player: VideoPlayer; + player: VideoPlayerBase; /** * The style of the video view - {@link ViewStyle} */