import { Connection } from '../../skychat/Connection.js'; import { Session } from '../../skychat/Session.js'; import { SanitizedUser, User } from '../../skychat/User.js'; import { PlayerChannelManager } from './PlayerChannelManager.js'; import { PlayerChannelScheduler, SanitizedScheduler } from './PlayerChannelScheduler.js'; export type QueuedVideoInfo = { user: SanitizedUser; video: VideoInfo; }; export type VideoInfo = { /** * Video type (currently only youtube supported) */ type: 'youtube' | 'twitch' | 'gallery' | 'iframe'; /** * Video data (for youtube, video id) */ id: string; /** * Duration in ms */ duration: number; /** * Video start time if video has started */ startTime?: number; /** * The video should skip this specified amount of ms */ startCursor: number; /** * Video title */ title: string; /** * Video thumbnail image */ thumb?: string; }; export type SanitizedPlayerChannel = { id: number; name: string; playing: boolean; currentMedia: { owner: string; title: string; } | undefined; schedule: SanitizedScheduler; }; export declare class PlayerChannel { static readonly HISTORY_LENGTH = 200; readonly id: number; name: string; readonly manager: PlayerChannelManager; readonly scheduler: PlayerChannelScheduler; readonly sessions: Session[]; queue: QueuedVideoInfo[]; history: QueuedVideoInfo[]; /** * Whether this channel is locked (= only OP can interact with it) */ locked: boolean; /** * Keeps track of the dates when user last played a media */ lastPlayedDates: { [userid: string]: Date; }; currentVideoInfo: QueuedVideoInfo | null; playNextTimeout: any; constructor(manager: PlayerChannelManager, id: number, name: string); /** * Schedule a media * @param media * @param start * @param duration */ schedule(media: VideoInfo, start: number, duration?: number): void; /** * Unschedule a media * @param start */ unschedule(start: number): void; /** * Play next video if possible */ playNext(): void; /** * Return whethers there is or not a next video to play */ hasNext(): boolean; /** * Returns whether there is currently something playing in the player */ isPlaying(): boolean; /** * Get current cursor in ms */ getCursor(): number; /** * Arm or re-arm the function that will play the next video (if available) */ armPlayNextTimeout(): void; /** * Move the cursor from the currently playing video * @param delta Duration in ms */ moveCursor(delta: number): void; /** * Empty the queue */ flushQueue(): void; /** * Skip the currently playing video */ skip(): void; /** * Whether the given video is already in the list or currently playing * @param video * @returns */ isVideoPlayingOrInQueue(video: VideoInfo): boolean; /** * Add one or multiple videos to the queue * @param video * @param user * @param options */ add(videoOrVideos: VideoInfo | VideoInfo[], user?: User, options?: { allowFailure: boolean; }): number; /** * Retrieve an entry in the queue if it exists. If not, returns null. */ getQueueEntry(type: string, id: VideoInfo['id']): QueuedVideoInfo | null; /** * Remove a specific video from the queue * @param video */ remove(video: VideoInfo): void; /** * Return whether a identifier is authorized to manage the player right now * @param identifier */ hasPlayerPermission(session: Session): boolean; /** * */ getPlayerData(): { current: QueuedVideoInfo | null; queue: QueuedVideoInfo[]; cursor: number; }; /** * Sync sessions in this channel */ sync(): void; /** * Shuffle the queued videos fairly, ensuring a round-robin among users */ fairShuffle(): void; /** * Sync a given list of connections * @param connections */ syncConnections(connections: Connection[]): void; /** * What will be sent to the client in the list of channels (All users have this info, even the one not in it) * This object is also saved in the plugin storage */ sanitized(): SanitizedPlayerChannel; }