fix(web): types

This commit is contained in:
Kamil Moskała
2026-03-26 14:36:26 +01:00
parent ee3cfb2ddf
commit 7715ec1556
4 changed files with 27 additions and 9 deletions
@@ -1,6 +1,6 @@
import { useEffect } from 'react'; import { useEffect } from 'react';
import type { AllPlayerEvents } from '../types/Events'; 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. * 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 * @param callback - The callback for the event
*/ */
export const useEvent = <T extends keyof AllPlayerEvents>( export const useEvent = <T extends keyof AllPlayerEvents>(
player: VideoPlayer, player: VideoPlayerBase,
event: T, event: T,
callback: AllPlayerEvents[T] callback: AllPlayerEvents[T]
) => { ) => {
@@ -1,11 +1,12 @@
import type { ListenerSubscription } from './EventEmitter';
import type { AllPlayerEvents } from './Events';
import type { IgnoreSilentSwitchMode } from './IgnoreSilentSwitchMode'; import type { IgnoreSilentSwitchMode } from './IgnoreSilentSwitchMode';
import type { MixAudioMode } from './MixAudioMode'; import type { MixAudioMode } from './MixAudioMode';
import type { TextTrack } from './TextTrack'; import type { TextTrack } from './TextTrack';
import type { VideoPlayerSourceBase } from './VideoPlayerSourceBase'; import type { VideoPlayerSourceBase } from './VideoPlayerSourceBase';
import type { VideoPlayerStatus } from './VideoPlayerStatus'; import type { VideoPlayerStatus } from './VideoPlayerStatus';
// eslint-disable-next-line @typescript-eslint/no-unused-vars import type { VideoConfig, VideoSource } from './VideoConfig';
import type { VideoConfig } from './VideoConfig';
export interface VideoPlayerBase { export interface VideoPlayerBase {
/** /**
@@ -152,7 +153,9 @@ export interface VideoPlayerBase {
* @note If you want to clear the source, you can pass null. * @note If you want to clear the source, you can pass null.
* see {@link VideoPlayerSourceBase} * see {@link VideoPlayerSourceBase}
*/ */
replaceSourceAsync(source: VideoPlayerSourceBase | null): Promise<void>; replaceSourceAsync(
source: VideoSource | VideoConfig | VideoPlayerSourceBase | null
): Promise<void>;
/** /**
* Get all available text tracks for the current source. * 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 * @returns The currently selected text track, or undefined if none is selected
*/ */
readonly selectedTrack?: TextTrack; 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 extends keyof AllPlayerEvents>(
event: Event,
callback: AllPlayerEvents[Event]
): ListenerSubscription;
} }
@@ -38,7 +38,7 @@ const wrapNativeViewManagerFunction = <T,>(
}; };
const updateProps = (manager: VideoViewViewManager, props: VideoViewProps) => { const updateProps = (manager: VideoViewViewManager, props: VideoViewProps) => {
manager.player = props.player.__getNativePlayer(); manager.player = (props.player as VideoPlayer).__getNativePlayer();
manager.controls = props.controls ?? false; manager.controls = props.controls ?? false;
manager.pictureInPicture = props.pictureInPicture ?? false; manager.pictureInPicture = props.pictureInPicture ?? false;
manager.autoEnterPictureInPicture = props.autoEnterPictureInPicture ?? false; manager.autoEnterPictureInPicture = props.autoEnterPictureInPicture ?? false;
@@ -3,13 +3,13 @@ import type { SurfaceType } from '../../spec/nitro/VideoViewViewManager.nitro';
import type { ListenerSubscription } from '../types/EventEmitter'; import type { ListenerSubscription } from '../types/EventEmitter';
import type { VideoViewEvents } from '../types/Events'; import type { VideoViewEvents } from '../types/Events';
import type { ResizeMode } from '../types/ResizeMode'; import type { ResizeMode } from '../types/ResizeMode';
import type { VideoPlayer } from '../VideoPlayer'; import type { VideoPlayerBase } from '../types/VideoPlayerBase';
export interface VideoViewProps extends Partial<VideoViewEvents>, ViewProps { export interface VideoViewProps extends Partial<VideoViewEvents>, 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} * The style of the video view - {@link ViewStyle}
*/ */