import PlayerConfiguration from '../models/PlayerConfiguration'; import UUID from '../models/UUID'; import NativeEventConsumer from '../events/NativeEventConsumer'; import PlayerState from '../models/PlayerState'; import NativeEvent from '../events/NativeEvent'; import PrestoPlayError from '../errors/PrestoPlayError'; import TrackManager from './TrackManager'; import PlayerExtension from './PlayerExtension'; import { PlayerExtensionConstructor } from './PlayerExtension'; import BaseEventEmitter from '../events/BaseEventEmitter'; import PlaybackStats from '../models/PlaybackStats'; /** * Represents the native player and provides methods for its control. * * Getter methods do not rely on the React Native bridge; they return cached values instead. * Cached values are updated via the event pipeline. * Setter methods use the React Native bridge to modify the native player. * * @group Classes */ export default class Player extends BaseEventEmitter implements NativeEventConsumer { /** @hidden */ readonly isApplePlayer: boolean; /** @hidden */ readonly ready: Promise; /** @hidden */ readonly id: UUID; private readonly logger; private extensions; private _fatalError; private _state; private _position; private _duration; private _playWhenReady; private _pictureInPictureMode; private _live; private _volume; private _playbackRate; private _playbackStats; private _liveStartTime; private _seekableRange; private _muted; private _playerConfiguration; /** @ignore */ constructor(applePlayer?: boolean); /** * Returns the track manager. */ getTrackManager(): TrackManager; /** * Returns the last fatal error that occurred. */ getFatalError(): PrestoPlayError | null; /** * Returns the current player state. */ getState(): PlayerState; /** * Returns the current playback position in milliseconds. */ getPosition(): number; /** * Returns the current player configuration, or null if it's unavailable. */ getPlayerConfiguration(): PlayerConfiguration | null; /** * Seeks to a new position. * @param newPosition - New position in milliseconds. */ setPosition(newPosition: number): Promise; /** * Returns whether the player is playing a live stream. */ isLive(): boolean; /** * Returns the duration of the current stream in milliseconds. */ getDuration(): number; getVolume(): number; setVolume(newVolume: number): Promise; /** * Returns the current playback speed, where 1 represents 'normal' speed. */ getPlaybackRate(): number; /** * Returns the current playback session metrics if available. Otherwise, returns null. * The values are reset each time a new stream is loaded. */ getPlaybackStats(): PlaybackStats | null; /** * Returns the live start time. * A live HLS stream has to have the `EXT-X-PROGRAM-DATE-TIME` defined. * NOTE: Not available on iOS for DASH. * @returns The live start time since the epoch in milliseconds; `null` if it is unknown or not applicable. */ getLiveStartTime(): number | null; /** * Returns the seekable range times in milliseconds * @returns The seekable range or null if unavailable */ getSeekableRange(): { startTime: number; endTime: number; } | null; /** * Set the playback speed, where 1 represents 'normal' speed. * * Note that setting speed for the online playback with high video quality * may result in video stuttering/lagging, and it is advised to disable * the ABR by setting one of the low video qualities * before changing the playback speed. * * @remarks On Android, when the requested speed is different from 1, * then the audio is disabled and otherwise is enabled automatically. * On iOS, when the requested speed is higher than 2, * then the audio is disabled. * * @param newPlaybackRate - The new speed at which the video is being played. */ setPlaybackRate(newPlaybackRate: number): Promise; isMuted(): boolean; setMuted(newMuted: boolean): Promise; isPlayWhenReady(): boolean; isPictureInPictureMode(): boolean; /** @ignore */ processNativeEvent(nativeEvent: NativeEvent): void; private onStateChanged; private onPositionChanged; private onDurationChanged; private onSeekableRangeChanged; private onLiveChanged; private onVolumeChanged; private onPlaybackRateChanged; private onStatsChanged; private onMutedChanged; private onPlayWhenReadyChanged; private onPictureInPictureModeChanged; private onError; private onPlayerClosed; open(playerConfiguration: PlayerConfiguration): Promise; play(): Promise; replay(): Promise; pause(): Promise; /** * The current playback is stopped. * * The player instance can still be used. * For example, a new stream can be loaded using {@link Player.open}. * Once stopped, the player is put into the {@link PlayerState.Idle} state. */ stop(): Promise; destroy(): Promise; supportsPictureInPicture(): Promise; enterPictureInPictureMode(): Promise; /** * Exits Picture-in-Picture (PiP) mode when supported by the platform. * * @platform Android * Android does not provide a programmatic API to exit PiP mode. * As a result, this method is a no-op on Android and resolves immediately * without performing any action. */ exitPictureInPictureMode(): Promise; /** @hidden */ addExtension(extension: T): void; /** @hidden */ removeExtension(extensionClass: PlayerExtensionConstructor): void; /** * Returns the extension of the specified type. * * Throws the {@link ErrorCode.PlayerExtensionNotFound} error * if the extension is not found. * * @param extensionClass - The extension class. */ getExtension(extensionClass: PlayerExtensionConstructor): T; /** * Called from \@castlabs/react-native-prestoplay-thumbnails * @hidden * @param playerId - * @returns */ getNativePlayer(playerId: string): any; private get nativePlayerModule(); /** * TODO when using new arch this is not needed */ private get nativeEventDispatcher(); }