saltfish
Version:
An interactive video-guided tour system for web applications
118 lines • 3.96 kB
TypeScript
import type { DeviceInfo } from '../utils/deviceDetection';
/**
* Configuration for video elements based on device type
*/
export interface VideoElementConfig {
playsInline: boolean;
muted: boolean;
controls: boolean;
preload: '' | 'metadata' | 'none' | 'auto';
additionalAttributes: Record<string, string>;
styles: Record<string, string>;
}
/**
* Configuration for UI controls based on device type
*/
export interface ControlsConfig {
buttonMinSize: {
width: string;
height: string;
};
useTouch: boolean;
progressUpdateInterval: number;
}
/**
* Autoplay strategy configuration
*/
export interface AutoplayConfig {
shouldStartMuted: boolean;
enableFallbackLoop: boolean;
fallbackTimeout: number;
requiresUserInteraction: boolean;
}
/**
* Abstract base class for device-specific playback handling
*/
export declare abstract class DevicePlaybackHandler {
protected deviceInfo: DeviceInfo;
constructor(deviceInfo: DeviceInfo);
/**
* Get device-specific video element configuration
*/
abstract getVideoElementConfig(): VideoElementConfig;
/**
* Get device-specific controls configuration
*/
abstract getControlsConfig(): ControlsConfig;
/**
* Get device-specific autoplay configuration
*/
abstract getAutoplayConfig(hasUserInteracted: boolean): AutoplayConfig;
/**
* Apply device-specific video element setup
*/
abstract configureVideoElement(video: HTMLVideoElement): void;
/**
* Apply device-specific control styling
*/
abstract configureControlElement(element: HTMLElement): void;
/**
* Handle device-specific play attempt
*/
abstract handlePlayAttempt(video: HTMLVideoElement, hasUserInteracted: boolean): Promise<boolean>;
/**
* Handle device-specific autoplay fallback
*/
abstract handleAutoplayFallback(video: HTMLVideoElement): Promise<void>;
/**
* Get appropriate progress update strategy
*/
abstract getProgressUpdateFrequency(isAutoplayFallback: boolean): number;
/**
* Clean up resources when handler is destroyed
*/
abstract destroy(): void;
/**
* Handle device change updates
*/
updateDeviceInfo(newDeviceInfo: DeviceInfo): void;
}
/**
* Mobile-specific playback handler
*/
export declare class MobilePlaybackHandler extends DevicePlaybackHandler {
getVideoElementConfig(): VideoElementConfig;
getControlsConfig(): ControlsConfig;
getAutoplayConfig(hasUserInteracted: boolean): AutoplayConfig;
configureVideoElement(video: HTMLVideoElement): void;
configureControlElement(element: HTMLElement): void;
handlePlayAttempt(video: HTMLVideoElement, hasUserInteracted: boolean): Promise<boolean>;
handleAutoplayFallback(video: HTMLVideoElement): Promise<void>;
/**
* Clean up resources when handler is destroyed
*/
destroy(): void;
getProgressUpdateFrequency(isAutoplayFallback: boolean): number;
}
/**
* Desktop-specific playback handler
*/
export declare class DesktopPlaybackHandler extends DevicePlaybackHandler {
getVideoElementConfig(): VideoElementConfig;
getControlsConfig(): ControlsConfig;
getAutoplayConfig(_hasUserInteracted: boolean): AutoplayConfig;
configureVideoElement(video: HTMLVideoElement): void;
configureControlElement(_element: HTMLElement): void;
handlePlayAttempt(video: HTMLVideoElement, _hasUserInteracted: boolean): Promise<boolean>;
handleAutoplayFallback(video: HTMLVideoElement): Promise<void>;
getProgressUpdateFrequency(_isAutoplayFallback: boolean): number;
/**
* Clean up resources when handler is destroyed
*/
destroy(): void;
}
/**
* Factory function to create appropriate device handler
*/
export declare function createDevicePlaybackHandler(deviceInfo: DeviceInfo): DevicePlaybackHandler;
//# sourceMappingURL=DevicePlaybackHandler.d.ts.map