@scarlett-player/embed 0.1.2 → 0.2.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.
package/dist/embed.js CHANGED
@@ -1498,7 +1498,8 @@ class ScarlettPlayer {
1498
1498
  autoplay: options.autoplay ?? false,
1499
1499
  loop: options.loop ?? false,
1500
1500
  volume: options.volume ?? 1,
1501
- muted: options.muted ?? false
1501
+ muted: options.muted ?? false,
1502
+ poster: options.poster ?? ""
1502
1503
  });
1503
1504
  this.logger = new Logger({
1504
1505
  level: options.logLevel ?? "warn",
@@ -1614,11 +1615,6 @@ class ScarlettPlayer {
1614
1615
  this.checkDestroyed();
1615
1616
  try {
1616
1617
  this.logger.debug("Play requested");
1617
- this.stateManager.update({
1618
- playing: true,
1619
- paused: false,
1620
- playbackState: "playing"
1621
- });
1622
1618
  this.eventBus.emit("playback:play", void 0);
1623
1619
  } catch (error) {
1624
1620
  this.errorHandler.handle(error, { operation: "play" });
@@ -1641,11 +1637,6 @@ class ScarlettPlayer {
1641
1637
  clearTimeout(this.seekResumeTimeout);
1642
1638
  this.seekResumeTimeout = null;
1643
1639
  }
1644
- this.stateManager.update({
1645
- playing: false,
1646
- paused: true,
1647
- playbackState: "paused"
1648
- });
1649
1640
  this.eventBus.emit("playback:pause", void 0);
1650
1641
  } catch (error) {
1651
1642
  this.errorHandler.handle(error, { operation: "pause" });
@@ -2127,56 +2118,6 @@ async function createPlayer(options) {
2127
2118
  await player.init();
2128
2119
  return player;
2129
2120
  }
2130
- var hlsConstructor = null;
2131
- var loadingPromise = null;
2132
- function supportsNativeHLS() {
2133
- if (typeof document === "undefined") return false;
2134
- const video = document.createElement("video");
2135
- return video.canPlayType("application/vnd.apple.mpegurl") !== "";
2136
- }
2137
- function isHlsJsSupported() {
2138
- if (hlsConstructor) {
2139
- return hlsConstructor.isSupported();
2140
- }
2141
- if (typeof window === "undefined") return false;
2142
- return !!(window.MediaSource || window.WebKitMediaSource);
2143
- }
2144
- function isHLSSupported() {
2145
- return supportsNativeHLS() || isHlsJsSupported();
2146
- }
2147
- async function loadHlsJs() {
2148
- if (hlsConstructor) {
2149
- return hlsConstructor;
2150
- }
2151
- if (loadingPromise) {
2152
- return loadingPromise;
2153
- }
2154
- loadingPromise = (async () => {
2155
- try {
2156
- const hlsModule = await import("./hls-BI8mYU47.js");
2157
- hlsConstructor = hlsModule.default;
2158
- if (!hlsConstructor.isSupported()) {
2159
- throw new Error("hls.js is not supported in this browser");
2160
- }
2161
- return hlsConstructor;
2162
- } catch (error) {
2163
- loadingPromise = null;
2164
- throw new Error(
2165
- `Failed to load hls.js: ${error instanceof Error ? error.message : "Unknown error"}`
2166
- );
2167
- }
2168
- })();
2169
- return loadingPromise;
2170
- }
2171
- function createHlsInstance(config) {
2172
- if (!hlsConstructor) {
2173
- throw new Error("hls.js is not loaded. Call loadHlsJs() first.");
2174
- }
2175
- return new hlsConstructor(config);
2176
- }
2177
- function getHlsConstructor() {
2178
- return hlsConstructor;
2179
- }
2180
2121
  function formatLevel(level) {
2181
2122
  if (level.name) {
2182
2123
  return level.name;
@@ -2429,6 +2370,56 @@ function setupVideoEventHandlers(video, api) {
2429
2370
  handlers.length = 0;
2430
2371
  };
2431
2372
  }
2373
+ var hlsConstructor = null;
2374
+ var loadingPromise = null;
2375
+ function supportsNativeHLS() {
2376
+ if (typeof document === "undefined") return false;
2377
+ const video = document.createElement("video");
2378
+ return video.canPlayType("application/vnd.apple.mpegurl") !== "";
2379
+ }
2380
+ function isHlsJsSupported() {
2381
+ if (hlsConstructor) {
2382
+ return hlsConstructor.isSupported();
2383
+ }
2384
+ if (typeof window === "undefined") return false;
2385
+ return !!(window.MediaSource || window.WebKitMediaSource);
2386
+ }
2387
+ function isHLSSupported() {
2388
+ return supportsNativeHLS() || isHlsJsSupported();
2389
+ }
2390
+ async function loadHlsJs() {
2391
+ if (hlsConstructor) {
2392
+ return hlsConstructor;
2393
+ }
2394
+ if (loadingPromise) {
2395
+ return loadingPromise;
2396
+ }
2397
+ loadingPromise = (async () => {
2398
+ try {
2399
+ const hlsModule = await import("./hls-BI8mYU47.js");
2400
+ hlsConstructor = hlsModule.default;
2401
+ if (!hlsConstructor.isSupported()) {
2402
+ throw new Error("hls.js is not supported in this browser");
2403
+ }
2404
+ return hlsConstructor;
2405
+ } catch (error) {
2406
+ loadingPromise = null;
2407
+ throw new Error(
2408
+ `Failed to load hls.js: ${error instanceof Error ? error.message : "Unknown error"}`
2409
+ );
2410
+ }
2411
+ })();
2412
+ return loadingPromise;
2413
+ }
2414
+ function createHlsInstance(config) {
2415
+ if (!hlsConstructor) {
2416
+ throw new Error("hls.js is not loaded. Call loadHlsJs() first.");
2417
+ }
2418
+ return new hlsConstructor(config);
2419
+ }
2420
+ function getHlsConstructor() {
2421
+ return hlsConstructor;
2422
+ }
2432
2423
  var DEFAULT_CONFIG = {
2433
2424
  debug: false,
2434
2425
  autoStartLoad: true,
@@ -2473,6 +2464,10 @@ function createHLSPlugin(config) {
2473
2464
  video.preload = "metadata";
2474
2465
  video.controls = false;
2475
2466
  video.playsInline = true;
2467
+ const poster = api?.getState("poster");
2468
+ if (poster) {
2469
+ video.poster = poster;
2470
+ }
2476
2471
  api?.container.appendChild(video);
2477
2472
  return video;
2478
2473
  };
@@ -4601,7 +4596,7 @@ async function create(options) {
4601
4596
  const config = { ...options };
4602
4597
  return createEmbedPlayer(container, config);
4603
4598
  }
4604
- const VERSION = "0.1.0";
4599
+ const VERSION = "0.1.2";
4605
4600
  const ScarlettPlayerAPI = {
4606
4601
  create,
4607
4602
  initAll,