@obipascal/player 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Player configuration options
3
+ */
4
+ export interface WontumPlayerConfig {
5
+ /** The S3 URL or HLS manifest URL */
6
+ src: string;
7
+ /** Container element or selector */
8
+ container: HTMLElement | string;
9
+ /** Autoplay video (subject to browser policies) */
10
+ autoplay?: boolean;
11
+ /** Start muted */
12
+ muted?: boolean;
13
+ /** Show player controls */
14
+ controls?: boolean;
15
+ /** Video poster image URL */
16
+ poster?: string;
17
+ /** Preload strategy: 'none' | 'metadata' | 'auto' */
18
+ preload?: "none" | "metadata" | "auto";
19
+ /** Custom player theme */
20
+ theme?: PlayerTheme;
21
+ /** S3 configuration for presigned URLs */
22
+ s3Config?: S3Config;
23
+ /** Analytics configuration */
24
+ analytics?: AnalyticsConfig;
25
+ /** HLS.js configuration override */
26
+ hlsConfig?: Partial<any>;
27
+ /** Subtitle tracks */
28
+ subtitles?: SubtitleTrack[];
29
+ /** Keep controls always visible (sticky) */
30
+ stickyControls?: boolean;
31
+ }
32
+ export interface PlayerTheme {
33
+ primaryColor?: string;
34
+ accentColor?: string;
35
+ fontFamily?: string;
36
+ controlsBackground?: string;
37
+ buttonHoverBg?: string;
38
+ progressHeight?: string;
39
+ borderRadius?: string;
40
+ }
41
+ export interface S3Config {
42
+ /** Function to sign URL and set CloudFront cookies (returns the original URL after setting cookies) */
43
+ signUrl?: (url: string) => Promise<string>;
44
+ /** Legacy: Function to generate presigned URL (for S3 direct access) */
45
+ getPresignedUrl?: (key: string) => Promise<string>;
46
+ /** CloudFront domain patterns to match (e.g., ['media.domain.com']) */
47
+ cloudFrontDomains?: string[];
48
+ /** S3 bucket region */
49
+ region?: string;
50
+ /** Custom S3 endpoint */
51
+ endpoint?: string;
52
+ }
53
+ export interface AnalyticsConfig {
54
+ /** Enable analytics */
55
+ enabled?: boolean;
56
+ /** Custom analytics endpoint */
57
+ endpoint?: string;
58
+ /** Session identifier */
59
+ sessionId?: string;
60
+ /** User identifier */
61
+ userId?: string;
62
+ /** Video identifier */
63
+ videoId?: string;
64
+ }
65
+ /**
66
+ * Player state
67
+ */
68
+ export interface PlayerState {
69
+ playing: boolean;
70
+ paused: boolean;
71
+ ended: boolean;
72
+ buffering: boolean;
73
+ currentTime: number;
74
+ duration: number;
75
+ volume: number;
76
+ muted: boolean;
77
+ playbackRate: number;
78
+ quality: string;
79
+ availableQualities: string[];
80
+ fullscreen: boolean;
81
+ }
82
+ /**
83
+ * Player events (compatible with Mux Player and HTML5 MediaElement events)
84
+ */
85
+ export type PlayerEventType = "play" | "pause" | "playing" | "ended" | "timeupdate" | "volumechange" | "ratechange" | "seeked" | "seeking" | "waiting" | "loadstart" | "loadeddata" | "loadedmetadata" | "canplay" | "canplaythrough" | "durationchange" | "progress" | "error" | "abort" | "emptied" | "stalled" | "suspend" | "qualitychange" | "fullscreenchange" | "resize";
86
+ export interface PlayerEvent {
87
+ type: PlayerEventType;
88
+ data?: any;
89
+ timestamp: number;
90
+ }
91
+ /**
92
+ * Analytics event types
93
+ */
94
+ export interface AnalyticsEvent {
95
+ eventType: string;
96
+ timestamp: number;
97
+ sessionId: string;
98
+ videoId?: string;
99
+ userId?: string;
100
+ data: Record<string, any>;
101
+ }
102
+ export interface QualityLevel {
103
+ height: number;
104
+ width: number;
105
+ bitrate: number;
106
+ name: string;
107
+ }
108
+ export interface SubtitleTrack {
109
+ label: string;
110
+ src: string;
111
+ srclang: string;
112
+ default?: boolean;
113
+ }
@@ -0,0 +1,51 @@
1
+ import { WontumPlayer } from './player';
2
+
3
+ /**
4
+ * UI Controller - Manages player controls and interface
5
+ */
6
+ export declare class UIController {
7
+ private container;
8
+ private player;
9
+ private controlsContainer;
10
+ private progressContainer;
11
+ private progressBar;
12
+ private playButton;
13
+ private skipBackwardButton;
14
+ private skipForwardButton;
15
+ private volumeButton;
16
+ private fullscreenButton;
17
+ private qualityButton;
18
+ private subtitleButton;
19
+ private speedButton;
20
+ private settingsButton;
21
+ private volumeSlider;
22
+ private progressInput;
23
+ private hideControlsTimeout;
24
+ private stickyControls;
25
+ constructor(container: HTMLElement, player: WontumPlayer);
26
+ private injectStyles;
27
+ private createProgressBar;
28
+ private createControls;
29
+ private setupEventListeners;
30
+ private setupPlayerEventListeners;
31
+ private updateSubtitleMenu;
32
+ private updateSpeedMenu;
33
+ private updateSettingsMenu;
34
+ private updateQualityMenu;
35
+ private showControls;
36
+ private hideControls;
37
+ private resetHideControlsTimeout;
38
+ private formatTime;
39
+ private getPlayIcon;
40
+ private getPauseIcon;
41
+ private getVolumeIcon;
42
+ private getMutedIcon;
43
+ private getFullscreenIcon;
44
+ private getQualityIcon;
45
+ private getSkipBackwardIcon;
46
+ private getSkipForwardIcon;
47
+ private getSubtitleIcon;
48
+ private getSpeedIcon;
49
+ private getSettingsIcon;
50
+ destroy(): void;
51
+ }