@scarlett-player/embed 1.8.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.
package/README.md CHANGED
@@ -11,6 +11,7 @@ Standalone, CDN-ready embed package for Scarlett Player. Drop in a single `<scri
11
11
  - **Multi-tenant Ready** - Brand customization via data attributes
12
12
  - **Unified API** - Single API for video, audio, and compact audio players
13
13
  - **iframe Support** - Helper page for URL-based iframe embeds
14
+ - **Sharing** - Opt-in share button on video: OS share sheet, copy link, embed code
14
15
 
15
16
  ## Installation
16
17
 
@@ -136,7 +137,7 @@ The simplest way to embed a player. Just add the script and use data attributes:
136
137
  | `data-controls` | boolean | `true` | Show/hide UI controls |
137
138
  | `data-big-play-button` | boolean | `true` | Centred play button over the poster (video only). Set `false` when your page draws its own play affordance |
138
139
  | `data-gestures` | boolean | `true` | Touch gestures on the picture (video only): double-tap the sides to seek, tap to toggle the controls. Touch only, by input type, so a mouse never triggers them. Set `false` if your page owns those gestures |
139
- | `data-brand-color` | string | - | Accent color (e.g., `#e50914`) |
140
+ | `data-brand-color` | string | - | Accent color (e.g., `#e50914`). `data-color` is accepted as an alias |
140
141
  | `data-primary-color` | string | - | Primary UI color |
141
142
  | `data-background-color` | string | - | Control bar background |
142
143
  | `data-hide-delay` | number | `3000` | Auto-hide delay (ms) |
@@ -148,6 +149,8 @@ The simplest way to embed a player. Just add the script and use data attributes:
148
149
  | `data-playback-rate` | number | `1.0` | Playback speed |
149
150
  | `data-start-time` | number | `0` | Start position (seconds) |
150
151
  | `data-class` | string | - | Custom CSS class(es) |
152
+ | `data-share-url` | string | - | Page URL to share. Setting it adds a share button to the video control bar; leaving it out changes nothing. Never the media `src`, see [Sharing](#sharing) |
153
+ | `data-embed-base-url` | string | - | URL of your `iframe.html` deployment. Only read alongside `data-share-url`, and only to enable the `embed` target in the share sheet |
151
154
 
152
155
  #### Audio-specific Attributes
153
156
 
@@ -157,6 +160,17 @@ The simplest way to embed a player. Just add the script and use data attributes:
157
160
  | `data-artist` | string | Artist/creator name |
158
161
  | `data-album` | string | Album name |
159
162
  | `data-artwork` | string | Album art / cover image URL |
163
+ | `data-playlist` | JSON | Array of `{ src, title?, artist?, poster?, artwork?, duration? }` (Full and Audio builds) |
164
+
165
+ #### Analytics Attributes (Full build)
166
+
167
+ | Attribute | Type | Description |
168
+ |-----------|------|-------------|
169
+ | `data-analytics-beacon-url` | string | Beacon endpoint. Setting it enables the analytics plugin |
170
+ | `data-analytics-video-id` | string | Video identifier sent with every beacon |
171
+ | `data-analytics-api-key` | string | Optional API key |
172
+
173
+ The auto-initializer also accepts `data-sp` in place of `data-scarlett-player`.
160
174
 
161
175
  ### 2. Programmatic API
162
176
 
@@ -254,15 +268,6 @@ For secure, sandboxed embeds:
254
268
  allow="autoplay; fullscreen; picture-in-picture"
255
269
  ></iframe>
256
270
 
257
- <!-- Audio player iframe -->
258
- <iframe
259
- src="https://assets.thestreamplatform.com/scarlett-player/latest/iframe.html?src=https://example.com/audio.m3u8&type=audio"
260
- width="100%"
261
- height="120"
262
- frameborder="0"
263
- allow="autoplay"
264
- ></iframe>
265
-
266
271
  <!-- With customization -->
267
272
  <iframe
268
273
  src="https://assets.thestreamplatform.com/scarlett-player/latest/iframe.html?src=https://example.com/stream.m3u8&autoplay=true&muted=true&brand-color=%23e50914"
@@ -276,13 +281,29 @@ For secure, sandboxed embeds:
276
281
 
277
282
  #### iframe URL Parameters
278
283
 
279
- All data attributes work as URL parameters (use kebab-case):
284
+ `iframe.html` loads the Full build and reads these URL parameters (kebab-case
285
+ or camelCase):
280
286
  - `src` (required)
281
- - `type` - `video`, `audio`, or `audio-mini`
282
- - `autoplay`, `muted`, `loop`
287
+ - `autoplay`, `muted`, `loop` - `true` or `1` to enable
288
+ - `controls` - `false` or `0` to hide the control bar
283
289
  - `poster`
284
290
  - `brand-color`, `primary-color`, `background-color`
285
291
  - `big-play-button` - omit to keep the centred play button, `false` or `0` to hide it
292
+ - `hide-delay`, `playback-rate`, `start-time`
293
+ - `share-url` - the page the viewer should be sent to. Setting it adds the share button; omitting it leaves the control bar unchanged. See [Sharing](#sharing)
294
+ - `embed-base-url` - optional canonical embed URL. Enables the **Embed** snippet target in the share sheet without leaking signed playback parameters
295
+
296
+ `share-url` is the one parameter the player cannot work out for itself. Inside
297
+ the iframe, `window.location.href` is the player page rather than your page, and
298
+ cross-origin rules stop anything reading the parent, so a share would otherwise
299
+ offer a link to the bare embed. Pass `embed-base-url` if you wish to offer an
300
+ `<iframe>` snippet option in the share sheet; omitting it excludes the embed
301
+ target to avoid leaking query parameters (such as signed media URLs) from
302
+ the running iframe.
303
+
304
+ The iframe page always creates a video player: it does not read a `type`
305
+ parameter in this version. For an audio or compact audio embed use the data
306
+ attributes or the programmatic API on your own page.
286
307
 
287
308
  ## Player Types
288
309
 
@@ -298,7 +319,7 @@ Takes an HLS manifest or a progressive video file.
298
319
 
299
320
  ### Audio Player
300
321
 
301
- Full-sized audio player with waveform, track info, and media session integration.
322
+ Full-sized audio player with album artwork, track info, and media session integration.
302
323
  Takes an HLS manifest or a progressive audio file.
303
324
 
304
325
  ```html
@@ -314,6 +335,52 @@ Minimal audio player for space-constrained layouts (64px height).
314
335
  <div data-scarlett-player data-src="audio.m3u8" data-type="audio-mini"></div>
315
336
  ```
316
337
 
338
+ ## Sharing
339
+
340
+ Off unless you ask for it. Give the embed the page URL and a share button
341
+ appears in the video control bar; leave it out and the control bar is exactly
342
+ what it has always been.
343
+
344
+ ```html
345
+ <div
346
+ data-scarlett-player
347
+ data-src="https://example.com/stream.m3u8"
348
+ data-share-url="https://example.com/watch/abc"
349
+ ></div>
350
+ ```
351
+
352
+ ```html
353
+ <iframe
354
+ src="https://assets.thestreamplatform.com/scarlett-player/latest/iframe.html?src=https%3A%2F%2Fexample.com%2Fstream.m3u8&share-url=https%3A%2F%2Fexample.com%2Fwatch%2Fabc"
355
+ width="640" height="360" frameborder="0" allowfullscreen
356
+ allow="autoplay; fullscreen; picture-in-picture"
357
+ ></iframe>
358
+ ```
359
+
360
+ The button opens the OS share sheet on a phone and an in-player sheet
361
+ everywhere else, offering copy link and, where a base URL is known, an embed
362
+ code. Everything it shares carries the current playback position.
363
+
364
+ **What gets shared is `data-share-url`, never `data-src`.** There is no
365
+ fallback, because playback URLs are frequently signed: sharing one would leak a
366
+ credential and hand the recipient a link that expires. That is also why the
367
+ embed cannot supply a default and the button stays off until you pass one.
368
+
369
+ A few limits worth knowing:
370
+
371
+ - **Video only.** The button is a registered control in the video control bar,
372
+ and the audio UIs render a fixed template with no control registry, so
373
+ `data-type="audio"` and `audio-mini` ignore `data-share-url`. The Audio build
374
+ ships no share plugin at all.
375
+ - **Needs the controls.** `data-controls="false"` removes the only way in, so
376
+ sharing is skipped along with the rest of the UI.
377
+ - **The embed code is opt-in separately.** The sheet's **Embed** option needs to
378
+ know where your `iframe.html` lives: pass `data-embed-base-url` (or `embed-base-url`
379
+ in `iframe.html`). Without it the option is left out rather than shown broken.
380
+
381
+ Full configuration (custom targets, icon, analytics hooks) lives in
382
+ [`@scarlett-player/share`](https://github.com/Hackney-Enterprises-Inc/scarlett-player/tree/main/packages/plugins/share).
383
+
317
384
  ## Multi-Tenant Branding
318
385
 
319
386
  Perfect for The Stream Platform's white-label needs:
@@ -342,9 +409,9 @@ All builds are available at `https://assets.thestreamplatform.com/scarlett-playe
342
409
 
343
410
  | Build | Files | Features |
344
411
  |-------|-------|----------|
345
- | **Full** | `embed.js` / `embed.umd.cjs` | Video + Audio + Analytics + Playlist + Media Session |
346
- | **Video** | `embed.video.js` / `embed.video.umd.cjs` | Video player only (lightweight) |
347
- | **Audio** | `embed.audio.js` / `embed.audio.umd.cjs` | Audio + Playlist + Media Session, on `hls.js/light` (no ID3) |
412
+ | **Full** | `embed.js` / `embed.umd.cjs` | Video + Audio + Analytics + Playlist + Media Session + Sharing |
413
+ | **Video** | `embed.video.js` / `embed.video.umd.cjs` | Video player only (lightweight), Sharing |
414
+ | **Audio** | `embed.audio.js` / `embed.audio.umd.cjs` | Audio + Playlist + Media Session, on `hls.js/light` (no ID3, no sharing) |
348
415
 
349
416
  **Which build should I use?**
350
417
 
@@ -394,13 +461,14 @@ const options: EmbedPlayerOptions = {
394
461
 
395
462
  ## Browser Support
396
463
 
397
- - Modern browsers (ES2020+)
398
- - Chrome/Edge 90+
399
- - Firefox 88+
464
+ - Chrome / Edge 80+
465
+ - Firefox 78+
400
466
  - Safari 14+
401
467
  - iOS Safari 14+
402
468
  - Android Chrome 90+
403
469
 
470
+ All three bundles are built for ES2020.
471
+
404
472
  ## Keyboard Shortcuts
405
473
 
406
474
  When `data-keyboard` is enabled (default):
@@ -480,8 +548,9 @@ MIT
480
548
 
481
549
  ## Documentation
482
550
 
483
- For detailed implementation docs including Laravel integration, see:
484
- - [Embed Implementation Guide](../../.claude/docs/embed-implementation.md)
551
+ - [Architecture](https://github.com/Hackney-Enterprises-Inc/scarlett-player/blob/main/docs/architecture.md)
552
+ - [Plugin authoring](https://github.com/Hackney-Enterprises-Inc/scarlett-player/blob/main/docs/plugin-authoring.md)
553
+ - Live demo: https://scarlettplayer.com
485
554
 
486
555
  ## Support
487
556
 
@@ -43,6 +43,15 @@ export interface PluginCreators {
43
43
  * gesture surface on a pure-mouse desktop with no touch to serve.
44
44
  */
45
45
  gestures?: (config: any) => Plugin;
46
+ /**
47
+ * Share sheet, copy link and embed codes.
48
+ *
49
+ * Video builds only, and only when the embed was given a share URL. The
50
+ * plugin contributes a control through `registerControl('share')` in
51
+ * `@scarlett-player/ui`, and the audio UIs render a fixed template with no
52
+ * control registry, so an audio player has nowhere to put the button.
53
+ */
54
+ share?: (config: any) => Plugin;
46
55
  }
47
56
  /**
48
57
  * Create an embed player with the given plugins
@@ -1 +1 @@
1
- {"version":3,"file":"create-embed.d.ts","sourceRoot":"","sources":["../src/create-embed.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAgB,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;A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