saltfish
Version:
An interactive video-guided tour system for web applications
233 lines • 6.47 kB
TypeScript
import { DeviceInfo } from '../utils/deviceDetection';
import type { Transcript } from '../types';
/**
* Defines how the video should behave when it reaches the end
*/
export type CompletionPolicy = 'auto' | 'manual';
/**
* Manager class for handling video playback and controls
*/
export declare class VideoManager {
private currentVideo;
private nextVideo;
private activeVideoIndex;
private container;
private progressBar;
private muteButton;
private ccButton;
private transcriptManager;
private preloadedVideos;
private updateInterval;
private animationFrameId;
private lastTimeupdateEvent;
private currentVideoUrl;
private nextVideoUrl;
private playbackPositions;
private completionPolicy;
private videoEndedCallback;
private deviceHandler;
private deviceChangeCleanup;
private hasUserInteracted;
private autoplayFallbackTimeout;
constructor();
/**
* Gets current device information
* @returns DeviceInfo object with device details
*/
getDeviceInfo(): DeviceInfo;
/**
* Checks if the current device is mobile
* @returns boolean indicating if device is mobile
*/
isMobileDevice(): boolean;
/**
* Handles device information changes (orientation, resize, etc.)
* @param deviceInfo Updated device information
*/
private handleDeviceChange;
/**
* Creates video player elements
* @param container - The container element for the video player
*/
create(container: HTMLElement): void;
/**
* Returns the currently active video element
*/
private getActiveVideo;
/**
* Returns the inactive video element (for preloading)
*/
private getInactiveVideo;
/**
* Swaps between the two video elements
*/
private swapVideos;
/**
* Loads a video from URL
* @param url - URL of the video to load
*/
loadVideo(url: string): Promise<void>;
/**
* Preloads a video for future playback to reduce transition delays
* @param url - URL of the video to preload
*/
preloadNextVideo(url: string): void;
/**
* Plays the video
*/
play(): void;
/**
* Pauses the video
*/
pause(): void;
/**
* Seeks to a specified time in the video
* @param time - The time to seek to in seconds
*/
seek(time: number): void;
/**
* Gets the current playback time of the video
* @returns The current time in seconds
*/
getCurrentTime(): number;
/**
* Gets the duration of the video
* @returns The duration in seconds
*/
getDuration(): number;
/**
* Gets the active video element
* @returns The video element
*/
getVideoElement(): HTMLVideoElement | null;
/**
* Destroys the video player and cleans up resources
*/
destroy(): void;
/**
* Adds event listeners to the video elements
*/
private addEventListeners;
/**
* Removes event listeners from the video elements
*/
private removeEventListeners;
/**
* Handles video ended event
*/
private handleVideoEnded;
/**
* Handles video time update (for debugging)
*/
private handleTimeUpdate;
/**
* Handles video error event
*/
private handleVideoError;
/**
* Starts updating the progress bar
*/
private startProgressUpdates;
/**
* Stops updating the progress bar
*/
private stopProgressUpdates;
/**
* Updates the progress bar based on current playback position
*/
private updateProgress;
/**
* Handles detailed time updates for smooth progress bar
*/
private handleDetailedTimeUpdate;
/**
* Sets the muted state of both video elements
* @param muted - Whether to mute the video
*/
setMuted(muted: boolean): void;
/**
* Toggles the muted state of the video
* @param event - Optional mouse event
*/
private toggleMute;
/**
* Updates the mute button icon based on muted state
*/
private updateMuteButtonIcon;
/**
* Checks if the video is currently muted
* @returns Whether the video is muted
*/
isMuted(): boolean;
/**
* Sets the completion policy for the video
* @param policy - The completion policy to use
* @param callback - Optional callback to execute when video ends
*/
setCompletionPolicy(policy: CompletionPolicy, callback?: () => void): void;
/**
* Updates the video ended handler based on completion policy
*/
private updateVideoEndedHandler;
/**
* Handles video ended event for automatic completion policy
*/
private handleAutoVideoEnded;
/**
* Handles video ended event for manual completion policy
*/
private handleManualVideoEnded;
/**
* Handles click on the progress bar to seek
*/
private handleProgressBarClick;
/**
* Handles seeking events to ensure smooth progress updates
*/
private handleSeeking;
/**
* Handles seeked events (seeking ended)
*/
private handleSeeked;
/**
* Hides the progress bar (used during autoplay fallback)
*/
hideProgressBar(): void;
/**
* Shows the progress bar and resets it to proper state
*/
showProgressBar(): void;
/**
* Hides the mute button (used during autoplay fallback)
*/
hideMuteButton(): void;
/**
* Shows the mute button
*/
showMuteButton(): void;
/**
* Marks that the user has interacted with the video player
* This is important for mobile autoplay policies
*/
markUserInteraction(): void;
/**
* Checks if user has interacted with the player
* @returns boolean indicating if user has interacted
*/
hasUserInteractedWith(): boolean;
/**
* Resets user interaction state (called when starting a new playlist)
*/
resetUserInteraction(): void;
/**
* Handles autoplay fallback click specifically for mobile Chrome
* @param videoElement - The video element to configure
*/
handleAutoplayFallbackClick(videoElement: HTMLVideoElement): void;
/**
* Load transcript data for the current video
* @param transcript - Transcript data to load
*/
loadTranscript(transcript: Transcript | null): void;
}
//# sourceMappingURL=VideoManager.d.ts.map