UNPKG

react-native-youtube-bridge

Version:

🎥 Easy-to-use YouTube player for React Native with cross-platform support

204 lines • 5.86 kB
import type { YoutubePlayerEvents, YoutubePlayerVars, EventCallback, WebYoutubePlayerController } from '@react-native-youtube-bridge/core'; import type WebviewYoutubePlayerController from './WebviewYoutubePlayerController'; export declare const INTERNAL_SET_CONTROLLER_INSTANCE: unique symbol; export declare const INTERNAL_UPDATE_PROGRESS_INTERVAL: unique symbol; export declare const INTERNAL_SET_PROGRESS_INTERVAL: unique symbol; type YoutubeEventType = keyof YoutubePlayerEvents; declare class YoutubePlayer { private listeners; private controller; private progressInterval; private videoId; private options; constructor(videoId: string | null | undefined, options?: YoutubePlayerVars); getVideoId(): string | null | undefined; getOptions(): YoutubePlayerVars | undefined; emit<T extends YoutubeEventType>(event: T, data: YoutubePlayerEvents[T]): void; [INTERNAL_SET_CONTROLLER_INSTANCE](controller: WebviewYoutubePlayerController | WebYoutubePlayerController | null): void; [INTERNAL_SET_PROGRESS_INTERVAL](interval: number): void; [INTERNAL_UPDATE_PROGRESS_INTERVAL](): void; subscribe<T extends YoutubeEventType>(event: T, callback: EventCallback<YoutubePlayerEvents[T]>): () => void; /** * Play the video. * @example * ```ts * player.play(); * ``` */ play(): void | Promise<void> | undefined; /** * Pause the video. * @example * ```ts * player.pause(); * ``` */ pause(): void | Promise<void> | undefined; /** * Stop the video. * @example * ```ts * player.stop(); * ``` */ stop(): void | Promise<void> | undefined; /** * Seek to a specific time in the video. * @param seconds - The time in seconds to seek to. * @param allowSeekAhead - Whether to allow seeking ahead. * @example * ```ts * player.seekTo(10, true); * ``` */ seekTo(seconds: number, allowSeekAhead?: boolean): Promise<void> | undefined; /** * Set the volume of the video. * @param volume - The volume to set. * @example * ```ts * player.setVolume(50); * ``` */ setVolume(volume: number): void | Promise<void> | undefined; /** * Get the volume of the video. * @example * ```ts * player.getVolume(); * ``` */ getVolume(): Promise<number> | undefined; /** * Mute the video. * @example * ```ts * player.mute(); * ``` */ mute(): void | Promise<void> | undefined; /** * Unmute the video. * @example * ```ts * player.unMute(); * ``` */ unMute(): void | Promise<void> | undefined; /** * Check if the video is muted. * @example * ```ts * player.isMuted(); * ``` */ isMuted(): Promise<boolean> | undefined; /** * Get the current time of the video. * @example * ```ts * player.getCurrentTime(); * ``` */ getCurrentTime(): Promise<number> | undefined; /** * Get the duration of the video. * @example * ```ts * player.getDuration(); * ``` */ getDuration(): Promise<number> | undefined; /** * Get the URL of the video. * @example * ```ts * player.getVideoUrl(); * ``` */ getVideoUrl(): Promise<string> | undefined; /** * Get the embed code of the video. * @example * ```ts * player.getVideoEmbedCode(); * ``` */ getVideoEmbedCode(): Promise<string> | undefined; /** * Get the playback rate of the video. * @example * ```ts * player.getPlaybackRate(); * ``` */ getPlaybackRate(): Promise<number> | undefined; /** * Set the playback rate of the video. * @param suggestedRate - The playback rate to set. * @example * ```ts * player.setPlaybackRate(1.5); * ``` */ setPlaybackRate(suggestedRate: number): Promise<void> | undefined; /** * Get the available playback rates of the video. * @example * ```ts * player.getAvailablePlaybackRates(); * ``` */ getAvailablePlaybackRates(): Promise<number[]> | undefined; /** * Get the state of the player. * @example * ```ts * player.getPlayerState(); * ``` */ getPlayerState(): Promise<number> | undefined; /** * Get the loaded fraction of the video. * @example * ```ts * player.getVideoLoadedFraction(); * ``` */ getVideoLoadedFraction(): Promise<number> | undefined; /** * Load a video by ID. * @param videoId - The ID of the video to load. * @param startSeconds - The time in seconds to start the video. * @param endSeconds - The time in seconds to end the video. * @example * ```ts * player.loadVideoById('AbZH7XWDW_k'); * ``` */ loadVideoById(videoId: string, startSeconds?: number, endSeconds?: number): void | Promise<void> | undefined; /** * Cue a video by ID. * @param videoId - The ID of the video to cue. * @param startSeconds - The time in seconds to start the video. * @param endSeconds - The time in seconds to end the video. * @example * ```ts * player.cueVideoById('AbZH7XWDW_k'); * ``` */ cueVideoById(videoId: string, startSeconds?: number, endSeconds?: number): void | Promise<void> | undefined; /** * Set the size of the player. * @param width - The width of the player. * @param height - The height of the player. * @example * ```ts * player.setSize(100, 100); * ``` */ setSize(width: number, height: number): void | Promise<void> | undefined; destroy(): void; } export default YoutubePlayer; //# sourceMappingURL=YoutubePlayer.d.ts.map