@dudgy/podcast-widget 0.2.0 → 0.3.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/dist/index.js CHANGED
@@ -49,6 +49,7 @@ var AudioEngine = class extends EventEmitter {
49
49
  this.onLoadedMetadata = () => {
50
50
  this.audio.playbackRate = this._playbackRate;
51
51
  this.emit("loaded-metadata", { duration: this.audio.duration });
52
+ this.onTimeUpdate();
52
53
  };
53
54
  this.onError = () => {
54
55
  const err = this.audio.error;
@@ -58,6 +59,7 @@ var AudioEngine = class extends EventEmitter {
58
59
  });
59
60
  };
60
61
  this.audio.addEventListener("timeupdate", this.onTimeUpdate);
62
+ this.audio.addEventListener("loadstart", this.onTimeUpdate);
61
63
  this.audio.addEventListener("ended", this.onEnded);
62
64
  this.audio.addEventListener("loadedmetadata", this.onLoadedMetadata);
63
65
  this.audio.addEventListener("error", this.onError);
@@ -143,6 +145,7 @@ var AudioEngine = class extends EventEmitter {
143
145
  // ─── Cleanup ───────────────────────────────────────────────────
144
146
  destroy() {
145
147
  this.audio.removeEventListener("timeupdate", this.onTimeUpdate);
148
+ this.audio.removeEventListener("loadstart", this.onTimeUpdate);
146
149
  this.audio.removeEventListener("ended", this.onEnded);
147
150
  this.audio.removeEventListener("loadedmetadata", this.onLoadedMetadata);
148
151
  this.audio.removeEventListener("error", this.onError);
@@ -198,10 +201,11 @@ var PlaybackStorage = class {
198
201
  } catch {
199
202
  }
200
203
  }
201
- cleanupPositions(currentEpisodeIds) {
204
+ /** Remove saved positions for episodes whose IDs aren't in `keepIds`. */
205
+ cleanupPositions(keepIds) {
202
206
  try {
203
207
  const positions = this.getPositions();
204
- const currentSet = new Set(currentEpisodeIds);
208
+ const currentSet = new Set(keepIds);
205
209
  let changed = false;
206
210
  for (const id of Object.keys(positions)) {
207
211
  if (!currentSet.has(id)) {
@@ -217,6 +221,19 @@ var PlaybackStorage = class {
217
221
  }
218
222
  };
219
223
 
224
+ // src/core/types.ts
225
+ var PLAYER_STATE_VERSION = 2;
226
+ var DEFAULT_CONFIG = {
227
+ storagePrefix: "podcast",
228
+ maxStoredPositions: 100,
229
+ positionSaveInterval: 5e3,
230
+ skipSeconds: 30,
231
+ episodeCacheTTL: 60 * 60 * 1e3
232
+ };
233
+ function resolveConfig(config) {
234
+ return { ...DEFAULT_CONFIG, ...config };
235
+ }
236
+
220
237
  // src/core/player-state.ts
221
238
  var PlayerStateStorage = class {
222
239
  stateKey;
@@ -231,11 +248,22 @@ var PlayerStateStorage = class {
231
248
  } catch {
232
249
  }
233
250
  }
251
+ /**
252
+ * Load saved state, migrating older formats. Returns null if nothing usable
253
+ * is saved.
254
+ *
255
+ * Unversioned (v1) state stored only an index into the episode list, which
256
+ * can't be trusted once the list changes, so only its volume is kept.
257
+ */
234
258
  loadState() {
235
259
  try {
236
260
  const raw = localStorage.getItem(this.stateKey);
237
261
  if (!raw) return null;
238
- return JSON.parse(raw);
262
+ const data = JSON.parse(raw);
263
+ if (!data || typeof data !== "object") return null;
264
+ const volume = isVolume(data.volume) ? data.volume : 1;
265
+ const episode = data.v === PLAYER_STATE_VERSION && isEpisode(data.episode) ? data.episode : null;
266
+ return { v: PLAYER_STATE_VERSION, episode, volume };
239
267
  } catch {
240
268
  return null;
241
269
  }
@@ -257,6 +285,14 @@ var PlayerStateStorage = class {
257
285
  }
258
286
  }
259
287
  };
288
+ function isVolume(v) {
289
+ return typeof v === "number" && v >= 0 && v <= 1;
290
+ }
291
+ function isEpisode(e) {
292
+ if (!e || typeof e !== "object") return false;
293
+ const ep = e;
294
+ return typeof ep.id === "string" && typeof ep.audioUrl === "string" && typeof ep.title === "string" && typeof ep.feedName === "string";
295
+ }
260
296
 
261
297
  // src/core/episode-provider.ts
262
298
  var FetchEpisodeProvider = class {
@@ -314,18 +350,6 @@ var FetchEpisodeProvider = class {
314
350
  }
315
351
  };
316
352
 
317
- // src/core/types.ts
318
- var DEFAULT_CONFIG = {
319
- storagePrefix: "podcast",
320
- maxStoredPositions: 100,
321
- positionSaveInterval: 5e3,
322
- skipSeconds: 30,
323
- episodeCacheTTL: 60 * 60 * 1e3
324
- };
325
- function resolveConfig(config) {
326
- return { ...DEFAULT_CONFIG, ...config };
327
- }
328
-
329
353
  // src/ui/utils.ts
330
354
  function formatTime(seconds) {
331
355
  if (isNaN(seconds) || seconds < 0) return "00:00";
@@ -368,20 +392,75 @@ function escapeHtml(str) {
368
392
  function getEpisodeImage(episode) {
369
393
  return episode.image || episode.feedImage || episode.artwork || "";
370
394
  }
395
+ function setArtwork(img, url) {
396
+ if (!img) return;
397
+ img.hidden = !url;
398
+ if (url) img.src = url;
399
+ else img.removeAttribute("src");
400
+ }
401
+ function hideBrokenImages(root) {
402
+ const onError = (e) => {
403
+ const t = e.target;
404
+ if (t instanceof HTMLImageElement && t.parentElement?.classList.contains("pw-art")) t.hidden = true;
405
+ };
406
+ root.addEventListener("error", onError, true);
407
+ return () => root.removeEventListener("error", onError, true);
408
+ }
409
+ function attachSeekTooltip(bar, getDuration) {
410
+ const tip = document.createElement("div");
411
+ tip.className = "pw-seek-tooltip";
412
+ tip.setAttribute("aria-hidden", "true");
413
+ tip.hidden = true;
414
+ bar.appendChild(tip);
415
+ const onMove = (e) => {
416
+ const duration = getDuration();
417
+ if (e.pointerType === "touch" || !(duration > 0)) {
418
+ tip.hidden = true;
419
+ return;
420
+ }
421
+ const rect = bar.getBoundingClientRect();
422
+ const frac = Math.min(1, Math.max(0, (e.clientX - rect.left) / rect.width));
423
+ tip.textContent = formatTime(frac * duration);
424
+ tip.hidden = false;
425
+ const half = tip.offsetWidth / 2;
426
+ tip.style.left = `${Math.min(rect.width - half, Math.max(half, frac * rect.width))}px`;
427
+ };
428
+ const onLeave = () => {
429
+ tip.hidden = true;
430
+ };
431
+ bar.addEventListener("pointermove", onMove);
432
+ bar.addEventListener("pointerleave", onLeave);
433
+ return () => {
434
+ bar.removeEventListener("pointermove", onMove);
435
+ bar.removeEventListener("pointerleave", onLeave);
436
+ tip.remove();
437
+ };
438
+ }
371
439
 
372
440
  // src/ui/html-templates.ts
373
441
  var ICONS = {
374
442
  play: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z"/></svg>',
375
443
  pause: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M6 19h4V5H6v14zm8-14v14h4V5h-4z"/></svg>',
376
- skipBack: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M11.99 5V1l-5 5 5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6h-2c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8zm-1.1 11h-.85v-3.26l-1.01.31v-.69l1.77-.63h.09V16zm4.28-1.76c0 .32-.03.6-.1.82s-.17.42-.29.57-.28.26-.45.33-.37.1-.59.10-.41-.03-.59-.1-.33-.18-.46-.33-.23-.34-.3-.57-.11-.5-.11-.82v-.74c0-.32.03-.6.1-.82s.17-.42.29-.57.28-.26.45-.33.37-.1.59-.10.41.03.59.1.33.18.46.33.23.34.3.57.11.5.11.82v.74zm-.85-.86c0-.19-.01-.35-.04-.48s-.07-.23-.12-.31-.11-.14-.19-.17-.16-.05-.25-.05-.18.02-.25.05-.14.09-.19.17-.09.18-.12.31-.04.29-.04.48v.97c0 .19.01.35.04.48s.07.24.12.32.11.14.19.17.16.05.25.05.18-.02.25-.05.14-.09.19-.17.09-.19.11-.32.04-.29.04-.48v-.97z"/></svg>',
377
- skipForward: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M18 13c0 3.31-2.69 6-6 6s-6-2.69-6-6 2.69-6 6-6v4l5-5-5-5v4c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8h-2zm-7.46 2.22v-.67c0-.31.02-.58.07-.8.05-.22.12-.42.22-.58.1-.16.22-.28.37-.37.14-.08.3-.12.5-.12.18 0 .35.04.49.12.14.08.27.2.37.37.1.16.17.36.22.58s.08.49.08.8v.67c0 .31-.03.58-.08.8-.05.22-.12.42-.22.58-.1.16-.23.28-.37.37-.14.08-.3.12-.49.12s-.36-.04-.5-.12c-.15-.08-.27-.2-.37-.37-.1-.16-.17-.36-.22-.58s-.07-.49-.07-.8zm.85.67c0 .25.04.45.11.59.07.14.2.21.38.21s.31-.07.38-.21c.07-.14.11-.34.11-.59v-.97c0-.25-.04-.45-.11-.59s-.2-.21-.38-.21-.31.07-.38.21c-.07.14-.11.34-.11.59v.97zm2.68-.87c0-.11.01-.21.04-.29.03-.08.06-.15.11-.2.05-.05.11-.09.18-.11s.14-.04.23-.04c.12 0 .22.02.3.07s.16.12.21.2.1.18.13.3c.03.11.05.24.05.38 0 .14-.02.27-.05.38-.03.11-.08.21-.13.3-.05.08-.12.15-.21.2s-.18.07-.3.07c-.09 0-.17-.01-.23-.04s-.13-.06-.18-.11c-.05-.05-.08-.12-.11-.2-.03-.08-.04-.18-.04-.29h-.01v-.62z"/></svg>',
444
+ // Plain circular arrows; the seconds are drawn as text on top (see renderSkipButton)
445
+ skipBack: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z"/></svg>',
446
+ skipForward: '<svg viewBox="0 0 24 24" fill="currentColor"><path transform="matrix(-1 0 0 1 24 0)" d="M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z"/></svg>',
378
447
  expand: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/></svg>',
379
448
  close: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>',
380
449
  volume: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02z"/></svg>',
381
450
  info: '<svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/></svg>',
382
451
  playlist: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"/></svg>',
452
+ note: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 3v10.55c-.59-.34-1.27-.55-2-.55-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4V7h4V3h-6z"/></svg>',
383
453
  download: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"/></svg>'
384
454
  };
455
+ function renderArtwork(className, imageUrl) {
456
+ const img = imageUrl ? `<img src="${escapeHtml(imageUrl)}" alt="">` : '<img alt="" hidden>';
457
+ return `<span class="pw-art ${className}">${img}${ICONS.note}</span>`;
458
+ }
459
+ function renderSkipButton(direction, seconds, extraClass = "") {
460
+ const label = `${direction === "back" ? "Back" : "Forward"} ${seconds} seconds`;
461
+ const icon = direction === "back" ? ICONS.skipBack : ICONS.skipForward;
462
+ return `<button class="pw-btn pw-btn--skip pw-btn--skip-${direction} ${extraClass}" aria-label="${label}">${icon}<span class="pw-skip-label" aria-hidden="true">${seconds}</span></button>`;
463
+ }
385
464
  var SPEED_OPTIONS = [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.5, 3];
386
465
  function renderPlaylistItem(episode, index, opts) {
387
466
  const imageUrl = getEpisodeImage(episode);
@@ -397,7 +476,7 @@ function renderPlaylistItem(episode, index, opts) {
397
476
  const feedLinkHtml = opts.feedPageUrl ? `<a href="${opts.feedPageUrl(episode.feedId)}" class="pw-view-feed" title="View show info" data-feed-link>${ICONS.info}</a>` : "";
398
477
  return `
399
478
  <div class="pw-playlist-item ${opts.isPlaying ? "pw-playing" : ""} ${hasSaved ? "pw-has-saved" : ""}" data-index="${index}">
400
- ${imageUrl ? `<img src="${escapeHtml(imageUrl)}" alt="${escapeHtml(episode.title)}" class="pw-episode-image">` : ""}
479
+ ${renderArtwork("pw-episode-image", imageUrl)}
401
480
  <div class="pw-episode-info">
402
481
  <div class="pw-episode-show">${escapeHtml(episode.feedName || "Unknown Show")}</div>
403
482
  <div class="pw-episode-title">${escapeHtml(episode.title)}</div>
@@ -433,6 +512,9 @@ var PlayerController = class extends EventEmitter {
433
512
  config;
434
513
  provider;
435
514
  episodes = [];
515
+ /** The loaded episode. May not be in `episodes` (e.g. restored after its feed moved on). */
516
+ currentEpisode = null;
517
+ /** Index of `currentEpisode` in `episodes`, or -1 if it isn't in the list. */
436
518
  currentIndex = -1;
437
519
  saveInterval = null;
438
520
  cleanupFns = [];
@@ -452,8 +534,8 @@ var PlayerController = class extends EventEmitter {
452
534
  this.engine.volume = savedState.volume;
453
535
  }
454
536
  this.engine.on("ended", () => {
455
- if (this.currentIndex >= 0) {
456
- this.storage.removePosition(this.episodes[this.currentIndex].id);
537
+ if (this.currentEpisode) {
538
+ this.storage.removePosition(this.currentEpisode.id);
457
539
  }
458
540
  this.stopPositionSaving();
459
541
  });
@@ -467,11 +549,17 @@ var PlayerController = class extends EventEmitter {
467
549
  // ─── Episode management ────────────────────────────────────────
468
550
  async loadEpisodes() {
469
551
  this.episodes = await this.provider.getEpisodes();
470
- this.storage.cleanupPositions(this.episodes.map((ep) => ep.id));
552
+ const saved = this.stateStorage.loadState()?.episode ?? null;
553
+ const keepIds = this.episodes.map((ep) => ep.id);
554
+ if (saved) keepIds.push(saved.id);
555
+ this.storage.cleanupPositions(keepIds);
471
556
  this.emit("episodes-loaded", { episodes: this.episodes });
472
- const savedState = this.stateStorage.loadState();
473
- if (savedState && savedState.currentEpisodeIndex >= 0 && savedState.currentEpisodeIndex < this.episodes.length) {
474
- this.loadEpisode(savedState.currentEpisodeIndex, false);
557
+ if (saved) {
558
+ const index = this.episodes.findIndex((ep) => ep.id === saved.id);
559
+ if (index >= 0) this.loadEpisode(index, false);
560
+ else this.select(saved, -1, false);
561
+ } else if (this.episodes.length > 0) {
562
+ this.loadEpisode(0, false);
475
563
  }
476
564
  return this.episodes;
477
565
  }
@@ -479,21 +567,22 @@ var PlayerController = class extends EventEmitter {
479
567
  return this.episodes;
480
568
  }
481
569
  getCurrentEpisode() {
482
- return this.currentIndex >= 0 ? this.episodes[this.currentIndex] : null;
570
+ return this.currentEpisode;
483
571
  }
572
+ /** Index of the current episode in the list, or -1 if none or not listed. */
484
573
  getCurrentIndex() {
485
574
  return this.currentIndex;
486
575
  }
487
576
  loadEpisode(index, autoPlay = false) {
488
577
  if (index < 0 || index >= this.episodes.length) return;
489
- const episode = this.episodes[index];
578
+ this.select(this.episodes[index], index, autoPlay);
579
+ }
580
+ select(episode, index, autoPlay) {
581
+ this.currentEpisode = episode;
490
582
  this.currentIndex = index;
491
583
  const savedPosition = this.storage.getPosition(episode.id);
492
584
  this.engine.load(episode.audioUrl, savedPosition ?? void 0);
493
- this.stateStorage.saveState({
494
- currentEpisodeIndex: this.currentIndex,
495
- volume: this.engine.volume
496
- });
585
+ this.persistState();
497
586
  this.emit("episode-change", { episode, index });
498
587
  this.emit("episode-display", {
499
588
  imageUrl: getEpisodeImage(episode),
@@ -508,9 +597,8 @@ var PlayerController = class extends EventEmitter {
508
597
  this.loadEpisode(index, true);
509
598
  }
510
599
  async play() {
511
- if (this.episodes.length === 0) return;
512
- if (this.currentIndex === -1) {
513
- this.playEpisode(0);
600
+ if (!this.currentEpisode) {
601
+ if (this.episodes.length > 0) this.playEpisode(0);
514
602
  return;
515
603
  }
516
604
  await this.engine.play();
@@ -526,9 +614,13 @@ var PlayerController = class extends EventEmitter {
526
614
  }
527
615
  setVolume(v) {
528
616
  this.engine.volume = v;
617
+ this.persistState();
618
+ }
619
+ persistState() {
529
620
  this.stateStorage.saveState({
530
- currentEpisodeIndex: this.currentIndex,
531
- volume: v
621
+ v: PLAYER_STATE_VERSION,
622
+ episode: this.currentEpisode,
623
+ volume: this.engine.volume
532
624
  });
533
625
  }
534
626
  getPlaylistHtml(feedPageUrl) {
@@ -554,8 +646,8 @@ var PlayerController = class extends EventEmitter {
554
646
  }
555
647
  }
556
648
  saveCurrentPosition() {
557
- if (this.currentIndex < 0 || !this.engine.hasSrc) return;
558
- const episode = this.episodes[this.currentIndex];
649
+ const episode = this.currentEpisode;
650
+ if (!episode || !this.engine.hasSrc) return;
559
651
  if (this.engine.currentTime > 10) {
560
652
  this.storage.savePosition(episode.id, this.engine.currentTime, episode.duration);
561
653
  }
@@ -604,16 +696,16 @@ var MiniPlayer = class extends EventEmitter {
604
696
  const c = this.controls;
605
697
  let controlsHtml = "";
606
698
  if (c.skipBackward) {
607
- controlsHtml += `<button class="pw-btn pw-btn--mini pw-btn--skip-back" aria-label="Back ${this.controller.config.skipSeconds} seconds">${ICONS.skipBack}</button>`;
699
+ controlsHtml += renderSkipButton("back", this.controller.config.skipSeconds, "pw-btn--mini");
608
700
  }
609
701
  if (c.playPause) {
610
702
  controlsHtml += `
611
- <button class="pw-btn pw-btn--mini pw-play-btn" aria-label="Play">${ICONS.play}</button>
612
- <button class="pw-btn pw-btn--mini pw-pause-btn" aria-label="Pause" style="display:none">${ICONS.pause}</button>
703
+ <button class="pw-btn pw-btn--mini pw-btn--play pw-play-btn" aria-label="Play">${ICONS.play}</button>
704
+ <button class="pw-btn pw-btn--mini pw-btn--play pw-pause-btn" aria-label="Pause" style="display:none">${ICONS.pause}</button>
613
705
  `;
614
706
  }
615
707
  if (c.skipForward) {
616
- controlsHtml += `<button class="pw-btn pw-btn--mini pw-btn--skip-fwd" aria-label="Forward ${this.controller.config.skipSeconds} seconds">${ICONS.skipForward}</button>`;
708
+ controlsHtml += renderSkipButton("fwd", this.controller.config.skipSeconds, "pw-btn--mini");
617
709
  }
618
710
  if (c.volume) {
619
711
  controlsHtml += `
@@ -639,7 +731,7 @@ var MiniPlayer = class extends EventEmitter {
639
731
  const progressHtml = c.progress ? `<div class="pw-mini-progress pw-progress-container" role="slider" aria-label="Seek" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"><div class="pw-mini-progress-bar"></div></div>` : "";
640
732
  this.container.innerHTML = `
641
733
  <div class="pw-mini">
642
- <img class="pw-mini-artwork" src="" alt="Podcast artwork" style="display:none">
734
+ ${renderArtwork("pw-mini-artwork")}
643
735
  <div class="pw-mini-info">
644
736
  <div class="pw-mini-title">No episode playing</div>
645
737
  <div class="pw-mini-show"></div>
@@ -649,7 +741,7 @@ var MiniPlayer = class extends EventEmitter {
649
741
  </div>
650
742
  ${c.playlist ? '<div class="pw-mini-playlist" style="display:none"></div>' : ""}
651
743
  `;
652
- this.artworkEl = this.container.querySelector(".pw-mini-artwork");
744
+ this.artworkEl = this.container.querySelector(".pw-mini-artwork img");
653
745
  this.titleEl = this.container.querySelector(".pw-mini-title");
654
746
  this.showEl = this.container.querySelector(".pw-mini-show");
655
747
  this.playBtn = this.container.querySelector(".pw-play-btn");
@@ -660,6 +752,7 @@ var MiniPlayer = class extends EventEmitter {
660
752
  }
661
753
  bindEvents() {
662
754
  const { engine } = this.controller;
755
+ this.cleanupFns.push(hideBrokenImages(this.container));
663
756
  this.addClick(".pw-play-btn", () => this.controller.play());
664
757
  this.addClick(".pw-pause-btn", () => this.controller.pause());
665
758
  this.addClick(".pw-btn--skip-back", () => engine.skipBackward());
@@ -676,6 +769,7 @@ var MiniPlayer = class extends EventEmitter {
676
769
  };
677
770
  this.progressContainer.addEventListener("click", handler);
678
771
  this.cleanupFns.push(() => this.progressContainer?.removeEventListener("click", handler));
772
+ this.cleanupFns.push(attachSeekTooltip(this.progressContainer, () => engine.duration));
679
773
  }
680
774
  const onTimeUpdate = (d) => {
681
775
  if (this.progressBar) {
@@ -719,14 +813,7 @@ var MiniPlayer = class extends EventEmitter {
719
813
  const imageUrl = getEpisodeImage(episode);
720
814
  if (this.titleEl) this.titleEl.textContent = episode.title;
721
815
  if (this.showEl) this.showEl.textContent = episode.feedName;
722
- if (this.artworkEl) {
723
- if (imageUrl) {
724
- this.artworkEl.src = imageUrl;
725
- this.artworkEl.style.display = "block";
726
- } else {
727
- this.artworkEl.style.display = "none";
728
- }
729
- }
816
+ setArtwork(this.artworkEl, imageUrl);
730
817
  }
731
818
  updatePlayPauseState(playing) {
732
819
  if (this.playBtn) this.playBtn.style.display = playing ? "none" : "flex";
@@ -845,7 +932,7 @@ var FullPlayer = class extends EventEmitter {
845
932
  const c = this.controls;
846
933
  let mainControlsHtml = "";
847
934
  if (c.skipBackward) {
848
- mainControlsHtml += `<button class="pw-btn pw-btn--skip pw-btn--skip-back" aria-label="Back ${this.controller.config.skipSeconds} seconds">${ICONS.skipBack}</button>`;
935
+ mainControlsHtml += renderSkipButton("back", this.controller.config.skipSeconds);
849
936
  }
850
937
  if (c.playPause) {
851
938
  mainControlsHtml += `
@@ -854,7 +941,7 @@ var FullPlayer = class extends EventEmitter {
854
941
  `;
855
942
  }
856
943
  if (c.skipForward) {
857
- mainControlsHtml += `<button class="pw-btn pw-btn--skip pw-btn--skip-fwd" aria-label="Forward ${this.controller.config.skipSeconds} seconds">${ICONS.skipForward}</button>`;
944
+ mainControlsHtml += renderSkipButton("fwd", this.controller.config.skipSeconds);
858
945
  }
859
946
  let secondaryHtml = "";
860
947
  if (c.volume) {
@@ -882,7 +969,7 @@ var FullPlayer = class extends EventEmitter {
882
969
  <div class="pw-hero-bg"></div>
883
970
  <button class="pw-btn-close" aria-label="Minimize player">${ICONS.close}</button>
884
971
  <div class="pw-now-playing">
885
- <img class="pw-artwork" src="" alt="Podcast artwork" style="display:none">
972
+ ${renderArtwork("pw-artwork")}
886
973
  <div class="pw-track-info">
887
974
  <div class="pw-track-name" aria-live="polite">Select an episode to play</div>
888
975
  <div class="pw-track-time" aria-live="off">00:00 / 00:00</div>
@@ -896,7 +983,7 @@ var FullPlayer = class extends EventEmitter {
896
983
  </div>
897
984
  ${playlistHtml}
898
985
  `;
899
- this.artworkEl = this.container.querySelector(".pw-artwork");
986
+ this.artworkEl = this.container.querySelector(".pw-artwork img");
900
987
  this.trackNameEl = this.container.querySelector(".pw-track-name");
901
988
  this.trackTimeEl = this.container.querySelector(".pw-track-time");
902
989
  this.playBtn = this.container.querySelector(".pw-play-btn");
@@ -908,6 +995,13 @@ var FullPlayer = class extends EventEmitter {
908
995
  }
909
996
  bindEvents() {
910
997
  const { engine } = this.controller;
998
+ this.cleanupFns.push(hideBrokenImages(this.container));
999
+ const art = this.artworkEl;
1000
+ if (art) {
1001
+ const onArtLoad = () => this.setHeroBackground(art.currentSrc || art.src);
1002
+ art.addEventListener("load", onArtLoad);
1003
+ this.cleanupFns.push(() => art.removeEventListener("load", onArtLoad));
1004
+ }
911
1005
  this.addClick(".pw-btn-close", () => this.hide());
912
1006
  if (this.backdrop) {
913
1007
  const handler = () => this.hide();
@@ -934,6 +1028,7 @@ var FullPlayer = class extends EventEmitter {
934
1028
  };
935
1029
  this.progressContainer.addEventListener("click", handler);
936
1030
  this.cleanupFns.push(() => this.progressContainer?.removeEventListener("click", handler));
1031
+ this.cleanupFns.push(attachSeekTooltip(this.progressContainer, () => engine.duration));
937
1032
  }
938
1033
  const onKeyDown = (e) => {
939
1034
  if (!this.isVisible) return;
@@ -1001,23 +1096,13 @@ var FullPlayer = class extends EventEmitter {
1001
1096
  if (this.trackNameEl) {
1002
1097
  this.trackNameEl.textContent = `${episode.feedName}: ${episode.title}`;
1003
1098
  }
1004
- if (this.artworkEl) {
1005
- if (imageUrl) {
1006
- this.artworkEl.src = imageUrl;
1007
- this.artworkEl.style.display = "block";
1008
- } else {
1009
- this.artworkEl.style.display = "none";
1010
- }
1011
- }
1012
- if (this.heroBg) {
1013
- if (imageUrl) {
1014
- this.heroBg.style.backgroundImage = `url("${imageUrl}")`;
1015
- this.heroBg.classList.add("pw-active");
1016
- } else {
1017
- this.heroBg.classList.remove("pw-active");
1018
- this.heroBg.style.backgroundImage = "";
1019
- }
1020
- }
1099
+ this.setHeroBackground("");
1100
+ setArtwork(this.artworkEl, imageUrl);
1101
+ }
1102
+ setHeroBackground(url) {
1103
+ if (!this.heroBg) return;
1104
+ this.heroBg.style.backgroundImage = url ? `url("${url.replace(/"/g, "%22")}")` : "";
1105
+ this.heroBg.classList.toggle("pw-active", !!url);
1021
1106
  }
1022
1107
  updatePlayPauseState(playing) {
1023
1108
  if (this.playBtn) this.playBtn.style.display = playing ? "none" : "flex";
@@ -1092,6 +1177,7 @@ export {
1092
1177
  FullPlayer,
1093
1178
  ICONS,
1094
1179
  MiniPlayer,
1180
+ PLAYER_STATE_VERSION,
1095
1181
  PlaybackStorage,
1096
1182
  PlayerController,
1097
1183
  PlayerStateStorage,