@scarlett-player/embed 1.7.0 → 1.8.1

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,21 @@
1
+ /**
2
+ * Scarlett Player - Audio Only Build
3
+ *
4
+ * Audio player with:
5
+ * - Audio UI (full + mini layouts)
6
+ * - HLS streaming (hls.js/light)
7
+ * - Native progressive playback (MP3, AAC, M4A, WAV, ...)
8
+ * - Playlist management
9
+ * - Media Session (lock screen controls)
10
+ *
11
+ * Does NOT include: Video UI, Analytics
12
+ * Use embed.js for full features or embed.video.js for video.
13
+ *
14
+ * @packageDocumentation
15
+ */
16
+ import type { ScarlettPlayerGlobal } from './types';
17
+ export type { EmbedConfig, EmbedPlayerOptions, ScarlettPlayerGlobal, PlayerType } from './types';
18
+ export { parseDataAttributes, applyContainerStyles, aspectRatioToPercent } from './parser';
19
+ declare const ScarlettPlayerAPI: ScarlettPlayerGlobal;
20
+ export default ScarlettPlayerAPI;
21
+ //# sourceMappingURL=index-audio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-audio.d.ts","sourceRoot":"","sources":["../src/index-audio.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAYH,OAAO,KAAK,EAAE,oBAAoB,EAAc,MAAM,SAAS,CAAC;AAKhE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACjG,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAoB3F,QAAA,MAAM,iBAAiB,EAAE,oBAIxB,CAAC;AASF,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Scarlett Player - Video Only Build
3
+ *
4
+ * Lightweight video player with:
5
+ * - Video UI (full video player controls)
6
+ * - HLS streaming
7
+ * - Native progressive playback (MP4, WebM, MOV, ...)
8
+ * - Sharing (opt in via `shareUrl`)
9
+ *
10
+ * Does NOT include: Audio UI, Analytics, Playlist, Media Session
11
+ * Use embed.js for full features or embed.audio.js for audio.
12
+ *
13
+ * @packageDocumentation
14
+ */
15
+ import type { ScarlettPlayerGlobal } from './types';
16
+ export type { EmbedConfig, EmbedPlayerOptions, ScarlettPlayerGlobal, PlayerType } from './types';
17
+ export { parseDataAttributes, applyContainerStyles, aspectRatioToPercent } from './parser';
18
+ declare const ScarlettPlayerAPI: ScarlettPlayerGlobal;
19
+ export default ScarlettPlayerAPI;
20
+ //# sourceMappingURL=index-video.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-video.d.ts","sourceRoot":"","sources":["../src/index-video.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AASH,OAAO,KAAK,EAAE,oBAAoB,EAAc,MAAM,SAAS,CAAC;AAKhE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACjG,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAqB3F,QAAA,MAAM,iBAAiB,EAAE,oBAIxB,CAAC;AASF,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Scarlett Player - Full Embed Build
3
+ *
4
+ * Complete player with all features:
5
+ * - Video UI (full video player controls)
6
+ * - Audio UI (full + mini audio player)
7
+ * - HLS streaming
8
+ * - Native progressive playback (MP4, WebM, MP3, ...)
9
+ * - Analytics
10
+ * - Playlist management
11
+ * - Media Session (lock screen controls)
12
+ * - Sharing (video, opt in via `shareUrl`)
13
+ *
14
+ * @packageDocumentation
15
+ */
16
+ import type { ScarlettPlayerGlobal } from './types';
17
+ export type { EmbedConfig, EmbedPlayerOptions, ScarlettPlayerGlobal, PlayerType } from './types';
18
+ export { parseDataAttributes, applyContainerStyles, aspectRatioToPercent } from './parser';
19
+ declare const ScarlettPlayerAPI: ScarlettPlayerGlobal;
20
+ export default ScarlettPlayerAPI;
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAaH,OAAO,KAAK,EAAE,oBAAoB,EAAc,MAAM,SAAS,CAAC;AAKhE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACjG,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAqB3F,QAAA,MAAM,iBAAiB,EAAE,oBAIxB,CAAC;AASF,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { EmbedConfig } from './types';
2
+ /**
3
+ * Parse data attributes from an element into EmbedConfig
4
+ * Supports multiple attribute naming conventions for flexibility
5
+ */
6
+ export declare function parseDataAttributes(element: HTMLElement): Partial<EmbedConfig>;
7
+ /**
8
+ * Convert aspect ratio string (e.g., "16:9") to percentage
9
+ */
10
+ export declare function aspectRatioToPercent(ratio: string): number;
11
+ /**
12
+ * Apply container styles based on config and player type
13
+ */
14
+ export declare function applyContainerStyles(container: HTMLElement, config: Partial<EmbedConfig>): void;
15
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,SAAS,CAAC;AAcvD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAuL9E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQ1D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,WAAW,EACtB,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,GAC3B,IAAI,CAiCN"}
@@ -0,0 +1,180 @@
1
+ /**
2
+ * Player type determines which UI to use
3
+ */
4
+ export type PlayerType = 'video' | 'audio' | 'audio-mini';
5
+ /**
6
+ * Configuration options that can be set via data attributes
7
+ */
8
+ export interface EmbedConfig {
9
+ /** Video/audio source URL (required) */
10
+ src: string;
11
+ /** Player type: 'video' (default), 'audio', or 'audio-mini' */
12
+ type?: PlayerType;
13
+ /** Autoplay the media */
14
+ autoplay?: boolean;
15
+ /** Mute the media */
16
+ muted?: boolean;
17
+ /** Poster/artwork image URL */
18
+ poster?: string;
19
+ /** Show/hide UI controls */
20
+ controls?: boolean;
21
+ /**
22
+ * Show the centred big play button over the poster (video only, default:
23
+ * true).
24
+ *
25
+ * Mirrors `UIPluginConfig.bigPlayButton` in `@scarlett-player/ui`, which is
26
+ * where the default lives: the embed forwards this to the video UI plugin
27
+ * only when it is set, so leaving it out keeps the plugin's own default
28
+ * rather than pinning a second copy of it here. Set it to `false` when the
29
+ * host page draws its own play affordance over the player. The audio UIs
30
+ * have no such control and ignore it.
31
+ */
32
+ bigPlayButton?: boolean;
33
+ /**
34
+ * Touch gestures on the video surface (video only, default: true).
35
+ *
36
+ * Double-tap the right of the picture to jump forward, the left to jump
37
+ * back, and tap once to toggle the controls. Touch only, decided by input
38
+ * type rather than user agent, so a mouse or pen never triggers any of it,
39
+ * and seeking is suppressed while casting and on live without a DVR window.
40
+ *
41
+ * Set it to `false` on a third-party page that owns those gestures itself.
42
+ */
43
+ gestures?: boolean;
44
+ /**
45
+ * Canonical page URL to share, which also turns the share button on (video
46
+ * only).
47
+ *
48
+ * There is no default and no fallback to the media `src`: playback URLs are
49
+ * frequently signed, so sharing one leaks a credential and produces a link
50
+ * that expires. Leaving this unset leaves the control bar exactly as it was,
51
+ * which is why an existing embed never grows a button it did not ask for.
52
+ *
53
+ * Inside an iframe embed this is the parameter that makes sharing correct at
54
+ * all. `window.location.href` there is the player page, not the page the
55
+ * viewer is on, and cross-origin rules stop the plugin reading the parent, so
56
+ * the host has to pass the real page in.
57
+ */
58
+ shareUrl?: string;
59
+ /**
60
+ * Base URL of the iframe embed page, which enables the `embed` share target.
61
+ *
62
+ * Only meaningful alongside {@link EmbedConfig.shareUrl}. The share sheet
63
+ * drops the `embed` target rather than offering a broken snippet when this is
64
+ * absent, so a share button without it still offers the OS sheet and copy
65
+ * link. `iframe.html` reads it from `embed-base-url` / `embedBaseUrl`.
66
+ */
67
+ embedBaseUrl?: string;
68
+ /** Brand/accent color for the player UI */
69
+ brandColor?: string;
70
+ /** Primary color for UI elements */
71
+ primaryColor?: string;
72
+ /** Background color for controls */
73
+ backgroundColor?: string;
74
+ /** Auto-hide controls delay in milliseconds */
75
+ hideDelay?: number;
76
+ /** Player width (CSS value) */
77
+ width?: string;
78
+ /** Player height (CSS value) */
79
+ height?: string;
80
+ /** Aspect ratio (e.g., "16:9", "4:3") - video only */
81
+ aspectRatio?: string;
82
+ /** Enable/disable keyboard shortcuts */
83
+ keyboard?: boolean;
84
+ /** Loop the media */
85
+ loop?: boolean;
86
+ /** Playback rate (speed) */
87
+ playbackRate?: number;
88
+ /** Start time in seconds */
89
+ startTime?: number;
90
+ /** Custom class name for the container */
91
+ className?: string;
92
+ /** Media title (for audio/media session) */
93
+ title?: string;
94
+ /** Artist name (for audio/media session) */
95
+ artist?: string;
96
+ /** Album name (for audio/media session) */
97
+ album?: string;
98
+ /** Artwork URL (alias for poster, for audio) */
99
+ artwork?: string;
100
+ /** Playlist items */
101
+ playlist?: PlaylistItem[];
102
+ /** Analytics configuration */
103
+ analytics?: AnalyticsConfig;
104
+ /** Watermark configuration */
105
+ watermark?: WatermarkConfig;
106
+ /** Captions configuration */
107
+ captions?: CaptionsConfig;
108
+ }
109
+ /**
110
+ * Playlist item configuration
111
+ */
112
+ export interface PlaylistItem {
113
+ src: string;
114
+ title?: string;
115
+ artist?: string;
116
+ poster?: string;
117
+ artwork?: string;
118
+ duration?: number;
119
+ }
120
+ /**
121
+ * Analytics configuration
122
+ */
123
+ export interface AnalyticsConfig {
124
+ beaconUrl?: string;
125
+ apiKey?: string;
126
+ videoId?: string;
127
+ }
128
+ /**
129
+ * Watermark configuration for embed
130
+ */
131
+ export interface WatermarkConfig {
132
+ text?: string;
133
+ imageUrl?: string;
134
+ position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center';
135
+ opacity?: number;
136
+ fontSize?: number;
137
+ dynamic?: boolean;
138
+ dynamicInterval?: number;
139
+ showDelay?: number;
140
+ }
141
+ /**
142
+ * Captions configuration for embed
143
+ */
144
+ export interface CaptionsConfig {
145
+ sources?: Array<{
146
+ language: string;
147
+ label: string;
148
+ src: string;
149
+ kind?: 'subtitles' | 'captions';
150
+ }>;
151
+ extractFromHLS?: boolean;
152
+ autoSelect?: boolean;
153
+ defaultLanguage?: string;
154
+ }
155
+ /**
156
+ * Programmatic API options
157
+ */
158
+ export interface EmbedPlayerOptions extends Partial<EmbedConfig> {
159
+ /** Target container element or selector */
160
+ container: string | HTMLElement;
161
+ }
162
+ /**
163
+ * Global ScarlettPlayer API exposed on window
164
+ */
165
+ export interface ScarlettPlayerGlobal {
166
+ /** Create a new player instance programmatically */
167
+ create(options: EmbedPlayerOptions): Promise<any>;
168
+ /** Initialize all players with data-scarlett-player attribute */
169
+ initAll(): Promise<void>;
170
+ /** Version of the embed package */
171
+ version: string;
172
+ /** Available player types in this build */
173
+ availableTypes: PlayerType[];
174
+ }
175
+ declare global {
176
+ interface Window {
177
+ ScarlettPlayer: ScarlettPlayerGlobal;
178
+ }
179
+ }
180
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,YAAY,CAAC;AAE1D;;GAEG;AACH,MAAM,WAA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M,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;KACjC,CAAC,CAAC;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,OAAO,CAAC,WAAW,CAAC;IAC9D,2CAA2C;IAC3C,SAAS,EAAE,MAAM,GAAG,WAAW,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,oDAAoD;IACpD,MAAM,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAClD,iEAAiE;IACjE,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,2CAA2C;IAC3C,cAAc,EAAE,UAAU,EAAE,CAAC;CAC9B;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,cAAc,EAAE,oBAAoB,CAAC;KACtC;CACF"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The package version this build was produced from, or '0.0.0-dev' when the
3
+ * build-time define is absent.
4
+ */
5
+ export declare const PKG_VERSION: string;
6
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAmBA;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,MAC8C,CAAC"}
package/iframe.html CHANGED
@@ -45,6 +45,34 @@
45
45
  loop: params.get('loop') === 'true' || params.get('loop') === '1',
46
46
  };
47
47
 
48
+ // Centred play button over the poster. Set only when the parameter is
49
+ // present: an untouched iframe URL must keep the ui plugin's default
50
+ // (shown), not pin a copy of it here. '0' counts as off alongside
51
+ // 'false', matching the controls parameter above.
52
+ const bigPlayButton = params.get('bigPlayButton') ?? params.get('big-play-button');
53
+ if (bigPlayButton !== null) {
54
+ config.bigPlayButton = bigPlayButton !== 'false' && bigPlayButton !== '0';
55
+ }
56
+
57
+ // Share button. This is the parameter the share plugin's iframe story is
58
+ // built on: in here window.location.href is the PLAYER page, and
59
+ // cross-origin rules stop anything reading the parent, so the real page
60
+ // has to be handed in. Absent means no button at all - an embed that has
61
+ // never passed it keeps the control bar it has always had.
62
+ const shareUrl = params.get('shareUrl') ?? params.get('share-url');
63
+ if (shareUrl) {
64
+ config.shareUrl = shareUrl;
65
+ }
66
+
67
+ // Embed share target. Opt-in via explicit canonical embed URL: we
68
+ // deliberately do not fall back to window.location.href because its query
69
+ // string may contain signed or credentialed playback URLs (src) that must
70
+ // not be leaked in shared embed snippets.
71
+ const embedBaseUrl = params.get('embedBaseUrl') ?? params.get('embed-base-url');
72
+ if (embedBaseUrl) {
73
+ config.embedBaseUrl = embedBaseUrl;
74
+ }
75
+
48
76
  // Parse numeric params
49
77
  const hideDelay = params.get('hideDelay') || params.get('hide-delay');
50
78
  if (hideDelay) {
@@ -61,15 +89,6 @@
61
89
  config.startTime = parseFloat(startTime);
62
90
  }
63
91
 
64
- // The page this embed lives on. Inside an iframe, window.location.href is
65
- // this player page, and cross-origin rules block reading the parent - so
66
- // without being told, a share from here would link to the bare player
67
- // rather than to the page the viewer is actually watching.
68
- const shareUrl = params.get('shareUrl') || params.get('share-url');
69
- if (shareUrl) {
70
- config.shareUrl = shareUrl;
71
- }
72
-
73
92
  // Validate src
74
93
  if (!config.src) {
75
94
  document.body.innerHTML = `
@@ -84,11 +103,33 @@
84
103
  </div>
85
104
  `;
86
105
  } else {
87
- // Import and initialize player
88
- import('./dist/embed.js')
106
+ // Import and initialize player.
107
+ //
108
+ // Two layouts ship this page and the bundle sits in a different place in
109
+ // each. scripts/upload-cdn.sh puts iframe.html BESIDE the bundles, so on
110
+ // the CDN the page is latest/iframe.html and the bundle is
111
+ // latest/embed.js; in the npm tarball the page is at the package root
112
+ // and the bundle is under dist/. The flat layout is tried first because
113
+ // it is the deployed one: './dist/embed.js' has been the only path here
114
+ // since the initial release (2b8fd69, 2025-12-14), and it 404s on the
115
+ // CDN, so this page has never worked there.
116
+ import('./embed.js')
117
+ .catch(() => import('./dist/embed.js'))
89
118
  .then((module) => {
90
- const player = module.create(config);
91
-
119
+ // The API object is the bundle's DEFAULT export: the ES build ends
120
+ // in `export { applyContainerStyles, aspectRatioToPercent,
121
+ // ScarlettPlayerAPI as default, parseDataAttributes }`, so
122
+ // `module.create` is undefined and `module.default.create` is the
123
+ // function. Loading the module also assigns the same object to
124
+ // window.ScarlettPlayer as a side effect.
125
+ //
126
+ // create() is async, so the null it returns for a missing container
127
+ // or an empty src arrives on the next tick; awaiting it here also
128
+ // routes a failed player creation into the catch below, which is
129
+ // where the viewer-facing error lives.
130
+ return module.default.create(config);
131
+ })
132
+ .then((player) => {
92
133
  if (!player) {
93
134
  console.error('Failed to create player');
94
135
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scarlett-player/embed",
3
- "version": "1.7.0",
3
+ "version": "1.8.1",
4
4
  "description": "Standalone CDN-ready embed package for Scarlett Player",
5
5
  "type": "module",
6
6
  "main": "./dist/embed.umd.cjs",
@@ -8,19 +8,19 @@
8
8
  "types": "./dist/index.d.ts",
9
9
  "exports": {
10
10
  ".": {
11
+ "types": "./dist/index.d.ts",
11
12
  "import": "./dist/embed.js",
12
- "require": "./dist/embed.umd.cjs",
13
- "types": "./dist/index.d.ts"
13
+ "require": "./dist/embed.umd.cjs"
14
14
  },
15
15
  "./video": {
16
+ "types": "./dist/index-video.d.ts",
16
17
  "import": "./dist/embed.video.js",
17
- "require": "./dist/embed.video.umd.cjs",
18
- "types": "./dist/index-video.d.ts"
18
+ "require": "./dist/embed.video.umd.cjs"
19
19
  },
20
20
  "./audio": {
21
+ "types": "./dist/index-audio.d.ts",
21
22
  "import": "./dist/embed.audio.js",
22
- "require": "./dist/embed.audio.umd.cjs",
23
- "types": "./dist/index-audio.d.ts"
23
+ "require": "./dist/embed.audio.umd.cjs"
24
24
  }
25
25
  },
26
26
  "files": [
@@ -50,15 +50,18 @@
50
50
  "homepage": "https://scarlettplayer.com",
51
51
  "dependencies": {
52
52
  "hls.js": "^1.6.0",
53
- "@scarlett-player/core": "1.7.0",
54
- "@scarlett-player/ui": "1.7.0",
55
- "@scarlett-player/analytics": "1.7.0",
56
- "@scarlett-player/hls": "1.7.0",
57
- "@scarlett-player/audio-ui": "1.7.0",
58
- "@scarlett-player/playlist": "1.7.0",
59
- "@scarlett-player/media-session": "1.7.0",
60
- "@scarlett-player/watermark": "1.7.0",
61
- "@scarlett-player/captions": "1.7.0"
53
+ "@scarlett-player/core": "1.8.1",
54
+ "@scarlett-player/hls": "1.8.1",
55
+ "@scarlett-player/native": "1.8.1",
56
+ "@scarlett-player/analytics": "1.8.1",
57
+ "@scarlett-player/audio-ui": "1.8.1",
58
+ "@scarlett-player/playlist": "1.8.1",
59
+ "@scarlett-player/media-session": "1.8.1",
60
+ "@scarlett-player/ui": "1.8.1",
61
+ "@scarlett-player/captions": "1.8.1",
62
+ "@scarlett-player/watermark": "1.8.1",
63
+ "@scarlett-player/gestures": "1.8.1",
64
+ "@scarlett-player/share": "1.8.1"
62
65
  },
63
66
  "devDependencies": {
64
67
  "@types/node": "^20.0.0",
@@ -71,7 +74,7 @@
71
74
  },
72
75
  "scripts": {
73
76
  "dev": "vite",
74
- "build": "tsc && vite build && BUILD_VIDEO=true vite build && BUILD_AUDIO=true vite build",
77
+ "build": "rimraf dist tsconfig.tsbuildinfo && tsc && vite build && BUILD_VIDEO=true vite build && BUILD_AUDIO=true vite build",
75
78
  "preview": "vite preview",
76
79
  "test": "vitest run",
77
80
  "test:watch": "vitest",