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 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 = <T extends keyof AllPlayerEvents>(
player: VideoPlayer,
player: VideoPlayerBase,
event: 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 { 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<void>;
replaceSourceAsync(
source: VideoSource | VideoConfig | VideoPlayerSourceBase | null
): Promise<void>;
/**
* 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 extends keyof AllPlayerEvents>(
event: Event,
callback: AllPlayerEvents[Event]
): ListenerSubscription;
}
@@ -38,7 +38,7 @@ const wrapNativeViewManagerFunction = <T,>(
};
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;
@@ -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<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}
*/