@banou/media-player 0.10.53 → 0.10.55

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.
Files changed (81) hide show
  1. package/dist/{ar-CWVutin3.js → ar-CSjwFY8l.js} +2 -0
  2. package/dist/{cs-CmwRGxyE.js → cs-Dk6IDwX9.js} +2 -0
  3. package/dist/{de-DLdKEf3t.js → de-G319tpSe.js} +2 -0
  4. package/dist/{el-Ckj-z6DX.js → el-CtRdEeUl.js} +2 -0
  5. package/dist/engine/index.d.ts +2 -0
  6. package/dist/engine/index.js +2 -2
  7. package/dist/engine/playback.d.ts +2 -0
  8. package/dist/engine/subtitle-convert.d.ts +8 -0
  9. package/dist/engine/subtitles.d.ts +2 -0
  10. package/dist/{engine-03XT1hpH.js → engine-tBJeFD6J.js} +341 -203
  11. package/dist/{es-419-zORhhU8D.js → es-419-BzuTB161.js} +2 -0
  12. package/dist/{fr-BtPmNkri.js → fr-BC0Ncjsm.js} +2 -0
  13. package/dist/{he-Bu79qEth.js → he-UutSGaSy.js} +2 -0
  14. package/dist/{hi-BsH3tSHa.js → hi-kNW0VH4d.js} +2 -0
  15. package/dist/{hu-BkYBW-YP.js → hu-UJBXN0lB.js} +2 -0
  16. package/dist/{id-nUaBCV4o.js → id-DYADKCdp.js} +2 -0
  17. package/dist/index.d.ts +4 -3
  18. package/dist/index.js +1188 -953
  19. package/dist/{it-CqPSHyFA.js → it-GodcqBoI.js} +2 -0
  20. package/dist/{ja-DTjvriHw.js → ja-r3FM4zNQ.js} +2 -0
  21. package/dist/{ko-dV8T7XOJ.js → ko-kNn9SZJT.js} +2 -0
  22. package/dist/labels.d.ts +2 -0
  23. package/dist/{ms-VZQ7BI0z.js → ms-B_95sgk7.js} +2 -0
  24. package/dist/{nl-Q6iDxbDz.js → nl-DUua8lM5.js} +2 -0
  25. package/dist/{pl-BN7bK74l.js → pl-DYN3cCvL.js} +2 -0
  26. package/dist/{pt-BR-CPFILeFW.js → pt-BR-CRH5nyyj.js} +2 -0
  27. package/dist/react/components/chrome.d.ts +3 -2
  28. package/dist/react/components/control-bar.d.ts +3 -2
  29. package/dist/react/hooks/use-playback.d.ts +1 -5
  30. package/dist/react/video-player.d.ts +29 -1
  31. package/dist/remote/index.d.ts +25 -2
  32. package/dist/remote/index.js +134 -68
  33. package/dist/remote/protocol.d.ts +22 -6
  34. package/dist/{ro-Bwcm-i3k.js → ro-lXdsKpft.js} +2 -0
  35. package/dist/{ru-D1FMz751.js → ru-Du_uJXdo.js} +2 -0
  36. package/dist/{sv-ci9K0Lkk.js → sv-CpEL6oGd.js} +2 -0
  37. package/dist/{th-DR-UBONQ.js → th-CQac_Jcd.js} +2 -0
  38. package/dist/{tr-BqhdfT22.js → tr-DLRAnIOh.js} +2 -0
  39. package/dist/{uk-8pkZqdni.js → uk-Cra5hJzT.js} +2 -0
  40. package/dist/{vi-3mKZ9G_M.js → vi-L2-IGJYQ.js} +2 -0
  41. package/dist/{zh-Hans-CDgigWKY.js → zh-Hans-Dp0UkPYn.js} +2 -0
  42. package/dist/{zh-Hant-3WSNI0ne.js → zh-Hant-CS16XV8X.js} +2 -0
  43. package/package.json +1 -1
  44. package/src/lib/engine/index.ts +3 -0
  45. package/src/lib/engine/playback.ts +18 -1
  46. package/src/lib/engine/subtitle-convert.ts +186 -0
  47. package/src/lib/engine/subtitles.ts +46 -7
  48. package/src/lib/index.tsx +7 -0
  49. package/src/lib/labels.ts +2 -0
  50. package/src/lib/locales/ar.json +2 -0
  51. package/src/lib/locales/cs.json +2 -0
  52. package/src/lib/locales/de.json +2 -0
  53. package/src/lib/locales/el.json +2 -0
  54. package/src/lib/locales/es-419.json +2 -0
  55. package/src/lib/locales/fr.json +2 -0
  56. package/src/lib/locales/he.json +2 -0
  57. package/src/lib/locales/hi.json +2 -0
  58. package/src/lib/locales/hu.json +2 -0
  59. package/src/lib/locales/id.json +2 -0
  60. package/src/lib/locales/it.json +2 -0
  61. package/src/lib/locales/ja.json +2 -0
  62. package/src/lib/locales/ko.json +2 -0
  63. package/src/lib/locales/ms.json +2 -0
  64. package/src/lib/locales/nl.json +2 -0
  65. package/src/lib/locales/pl.json +2 -0
  66. package/src/lib/locales/pt-BR.json +2 -0
  67. package/src/lib/locales/ro.json +2 -0
  68. package/src/lib/locales/ru.json +2 -0
  69. package/src/lib/locales/sv.json +2 -0
  70. package/src/lib/locales/th.json +2 -0
  71. package/src/lib/locales/tr.json +2 -0
  72. package/src/lib/locales/uk.json +2 -0
  73. package/src/lib/locales/vi.json +2 -0
  74. package/src/lib/locales/zh-Hans.json +2 -0
  75. package/src/lib/locales/zh-Hant.json +2 -0
  76. package/src/lib/react/components/chrome.tsx +4 -3
  77. package/src/lib/react/components/control-bar.tsx +51 -6
  78. package/src/lib/react/hooks/use-playback.ts +207 -15
  79. package/src/lib/react/video-player.tsx +116 -3
  80. package/src/lib/remote/index.ts +149 -12
  81. package/src/lib/remote/protocol.ts +32 -7
@@ -14,6 +14,7 @@ var e = "Audio", t = "Copiato", n = "Copia", r = "Disattivati", i = "Disattiva a
14
14
  "Full screen (f)": "Schermo intero (f)",
15
15
  Mute: i,
16
16
  "Mute (m)": "Disattiva audio (m)",
17
+ "Next episode": "Episodio successivo",
17
18
  "Normalize volume": "Normalizza volume",
18
19
  "Now click your browser's pop out button": "Ora fai clic sul pulsante picture in picture del browser",
19
20
  Pause: a,
@@ -24,6 +25,7 @@ var e = "Audio", t = "Copiato", n = "Copia", r = "Disattivati", i = "Disattiva a
24
25
  "Playback errors ({count})": "Errori di riproduzione ({count})",
25
26
  "Playback failed": "Riproduzione non riuscita",
26
27
  "Playback speed": "Velocità",
28
+ "Previous episode": "Episodio precedente",
27
29
  "Put the subtitles in the picture": "Inserisci i sottotitoli nell’immagine",
28
30
  "Put the subtitles in the video": "Inserisci i sottotitoli nel video",
29
31
  Quality: s,
@@ -14,6 +14,7 @@ var e = "音声", t = "コピーしました", n = "コピー", r = "オフ", i
14
14
  "Full screen (f)": "全画面 (f)",
15
15
  Mute: i,
16
16
  "Mute (m)": "ミュート (m)",
17
+ "Next episode": "次のエピソード",
17
18
  "Normalize volume": "音量を均一化",
18
19
  "Now click your browser's pop out button": "ブラウザのピクチャー イン ピクチャー ボタンをクリックしてください",
19
20
  Pause: a,
@@ -24,6 +25,7 @@ var e = "音声", t = "コピーしました", n = "コピー", r = "オフ", i
24
25
  "Playback errors ({count})": "再生エラー ({count})",
25
26
  "Playback failed": "再生に失敗しました",
26
27
  "Playback speed": "再生速度",
28
+ "Previous episode": "前のエピソード",
27
29
  "Put the subtitles in the picture": "字幕を映像に焼き込む",
28
30
  "Put the subtitles in the video": "字幕を動画に焼き込む",
29
31
  Quality: s,
@@ -14,6 +14,7 @@ var e = "오디오", t = "복사됨", n = "복사", r = "사용 안함", i = "
14
14
  "Full screen (f)": "전체 화면 (f)",
15
15
  Mute: i,
16
16
  "Mute (m)": "음소거 (m)",
17
+ "Next episode": "다음 에피소드",
17
18
  "Normalize volume": "음량 평준화",
18
19
  "Now click your browser's pop out button": "이제 브라우저의 PIP 버튼을 클릭하세요",
19
20
  Pause: a,
@@ -24,6 +25,7 @@ var e = "오디오", t = "복사됨", n = "복사", r = "사용 안함", i = "
24
25
  "Playback errors ({count})": "재생 오류 ({count})",
25
26
  "Playback failed": "재생하지 못했습니다",
26
27
  "Playback speed": "재생 속도",
28
+ "Previous episode": "이전 에피소드",
27
29
  "Put the subtitles in the picture": "자막을 화면에 넣기",
28
30
  "Put the subtitles in the video": "자막을 동영상에 넣기",
29
31
  Quality: s,
package/dist/labels.d.ts CHANGED
@@ -34,6 +34,8 @@ export declare const LABELS: {
34
34
  readonly speed: '{rate}x';
35
35
  readonly normalizeVolume: 'Normalize volume';
36
36
  readonly autoplayNext: 'Autoplay next episode';
37
+ readonly previousEpisode: 'Previous episode';
38
+ readonly nextEpisode: 'Next episode';
37
39
  readonly unavailable: 'Unavailable';
38
40
  readonly switchFailed: 'Could not switch. Try again.';
39
41
  readonly track: 'Track {number}';
@@ -14,6 +14,7 @@ var e = "Audio", t = "Disalin", n = "Salin", r = "Mati", i = "Redam", a = "Jeda"
14
14
  "Full screen (f)": "Skrin penuh (f)",
15
15
  Mute: i,
16
16
  "Mute (m)": "Redam (m)",
17
+ "Next episode": "Episod seterusnya",
17
18
  "Normalize volume": "Seimbangkan kelantangan",
18
19
  "Now click your browser's pop out button": "Sekarang klik butang gambar dalam gambar pada pelayar anda",
19
20
  Pause: a,
@@ -24,6 +25,7 @@ var e = "Audio", t = "Disalin", n = "Salin", r = "Mati", i = "Redam", a = "Jeda"
24
25
  "Playback errors ({count})": "Ralat main balik ({count})",
25
26
  "Playback failed": "Main balik gagal",
26
27
  "Playback speed": "Kelajuan main balik",
28
+ "Previous episode": "Episod sebelumnya",
27
29
  "Put the subtitles in the picture": "Benamkan sari kata dalam gambar",
28
30
  "Put the subtitles in the video": "Benamkan sari kata dalam video",
29
31
  Quality: s,
@@ -14,6 +14,7 @@ var e = "Audio", t = "Gekopieerd", n = "Kopiëren", r = "Uit", i = "Dempen", a =
14
14
  "Full screen (f)": "Volledig scherm (f)",
15
15
  Mute: i,
16
16
  "Mute (m)": "Dempen (m)",
17
+ "Next episode": "Volgende aflevering",
17
18
  "Normalize volume": "Volume gelijktrekken",
18
19
  "Now click your browser's pop out button": "Klik nu op de beeld-in-beeldknop van je browser",
19
20
  Pause: a,
@@ -24,6 +25,7 @@ var e = "Audio", t = "Gekopieerd", n = "Kopiëren", r = "Uit", i = "Dempen", a =
24
25
  "Playback errors ({count})": "Afspeelfouten ({count})",
25
26
  "Playback failed": "Afspelen mislukt",
26
27
  "Playback speed": "Afspeelsnelheid",
28
+ "Previous episode": "Vorige aflevering",
27
29
  "Put the subtitles in the picture": "Ondertitels in het beeld branden",
28
30
  "Put the subtitles in the video": "Ondertitels in de video branden",
29
31
  Quality: s,
@@ -14,6 +14,7 @@ var e = "Dźwięk", t = "Skopiowano", n = "Kopiuj", r = "Wyłączone", i = "Wyci
14
14
  "Full screen (f)": "Pełny ekran (f)",
15
15
  Mute: i,
16
16
  "Mute (m)": "Wycisz (m)",
17
+ "Next episode": "Następny odcinek",
17
18
  "Normalize volume": "Wyrównaj głośność",
18
19
  "Now click your browser's pop out button": "Teraz kliknij przycisk obrazu w obrazie w przeglądarce",
19
20
  Pause: a,
@@ -24,6 +25,7 @@ var e = "Dźwięk", t = "Skopiowano", n = "Kopiuj", r = "Wyłączone", i = "Wyci
24
25
  "Playback errors ({count})": "Błędy odtwarzania ({count})",
25
26
  "Playback failed": "Nie udało się odtworzyć",
26
27
  "Playback speed": "Szybkość",
28
+ "Previous episode": "Poprzedni odcinek",
27
29
  "Put the subtitles in the picture": "Wtop napisy w obraz",
28
30
  "Put the subtitles in the video": "Wtop napisy w wideo",
29
31
  Quality: s,
@@ -14,6 +14,7 @@ var e = "Áudio", t = "Copiado", n = "Copiar", r = "Desativadas", i = "Desativar
14
14
  "Full screen (f)": "Tela cheia (f)",
15
15
  Mute: i,
16
16
  "Mute (m)": "Desativar som (m)",
17
+ "Next episode": "Próximo episódio",
17
18
  "Normalize volume": "Normalizar volume",
18
19
  "Now click your browser's pop out button": "Agora clique no botão de picture-in-picture do seu navegador",
19
20
  Pause: a,
@@ -24,6 +25,7 @@ var e = "Áudio", t = "Copiado", n = "Copiar", r = "Desativadas", i = "Desativar
24
25
  "Playback errors ({count})": "Erros de reprodução ({count})",
25
26
  "Playback failed": "Falha na reprodução",
26
27
  "Playback speed": "Velocidade",
28
+ "Previous episode": "Episódio anterior",
27
29
  "Put the subtitles in the picture": "Colocar as legendas na imagem",
28
30
  "Put the subtitles in the video": "Colocar as legendas no vídeo",
29
31
  Quality: s,
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode, Ref } from 'react';
2
- import type { HostFullscreen } from '../video-player';
2
+ import type { EpisodeNavigation, HostFullscreen } from '../video-player';
3
3
  export type ChromeProps = {
4
4
  ref?: Ref<HTMLDivElement> | ((element: HTMLDivElement | null) => void);
5
5
  /** Absent means render no video element: the media belongs to someone else and arrives as children. */
@@ -14,7 +14,8 @@ export type ChromeProps = {
14
14
  fullscreen?: HostFullscreen;
15
15
  /** False leaves the last ending out of the skip offer. */
16
16
  endingOffered: boolean;
17
+ episodeNavigation?: EpisodeNavigation;
17
18
  children?: ReactNode;
18
19
  };
19
- export declare const Chrome: ({ ref, onVideoRef, onSubtitleRef, overlay, controls, shortcuts, fullscreen, endingOffered, children }: ChromeProps) => import("@emotion/react/jsx-runtime").JSX.Element;
20
+ export declare const Chrome: ({ ref, onVideoRef, onSubtitleRef, overlay, controls, shortcuts, fullscreen, endingOffered, episodeNavigation, children }: ChromeProps) => import("@emotion/react/jsx-runtime").JSX.Element;
20
21
  export default Chrome;
@@ -1,8 +1,9 @@
1
1
  import type { RefObject } from 'react';
2
- import type { HostFullscreen } from '../video-player';
3
- export declare const ControlBar: ({ shortcuts, root, fullscreen: host }: {
2
+ import type { EpisodeNavigation, HostFullscreen } from '../video-player';
3
+ export declare const ControlBar: ({ shortcuts, root, fullscreen: host, episodeNavigation }: {
4
4
  shortcuts?: 'window' | 'player';
5
5
  root: RefObject<HTMLDivElement | null>;
6
6
  fullscreen?: HostFullscreen;
7
+ episodeNavigation?: EpisodeNavigation;
7
8
  }) => import("@emotion/react/jsx-runtime").JSX.Element;
8
9
  export default ControlBar;
@@ -1,9 +1,5 @@
1
1
  import type { PlaybackOutput } from '../../engine';
2
2
  import type { MediaPlayerLocalOptions } from '../video-player';
3
- /**
4
- * Owns the engine for the life of a source: start, teardown, and every piece of state the pipeline
5
- * discovers. Nothing is mirrored in React state, so the store is the only place any of it lives.
6
- */
7
3
  export declare const usePlayback: (video: HTMLVideoElement | null, subtitles: HTMLElement | null,
8
4
  /** null when the media is remote: there are no bytes, so there is no pipeline to run. */
9
- options: MediaPlayerLocalOptions | null, onOutput?: (output: PlaybackOutput) => void) => void;
5
+ options: MediaPlayerLocalOptions | null, onOutput?: (output: PlaybackOutput) => void, externalSubtitlesRevision?: number) => void;
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from 'react';
2
- import type { MediaChapter } from '../engine';
2
+ import type { ExternalSubtitleFormat, MediaChapter } from '../engine';
3
3
  import type { DownloadedRange } from './source-feature';
4
4
  import type { DelegatedTracks, ExternalThumbnails, PassThroughPictureInPicture, PlayerMedia } from './media';
5
5
  import type { ExposePlayerOptions } from '../remote';
@@ -33,6 +33,27 @@ export type HostFullscreen = {
33
33
  */
34
34
  request: () => void;
35
35
  };
36
+ /** One step in episode navigation (previous or next episode) shown next to the play control. */
37
+ export type EpisodeStep = {
38
+ /** Custom tooltip and accessible label for this button; falls back to the localized default label. */
39
+ title?: string;
40
+ /** Invoked when the viewer clicks this button. */
41
+ request: () => void;
42
+ };
43
+ /** Previous and next episode actions shown next to the play button when present. */
44
+ export type EpisodeNavigation = {
45
+ previous?: EpisodeStep | null;
46
+ next?: EpisodeStep | null;
47
+ };
48
+ /** An external subtitle track loaded outside the media container and rendered via `SubtitleRenderer`. */
49
+ export type ExternalSubtitleTrack = {
50
+ id: string;
51
+ language: string;
52
+ label: string;
53
+ format: ExternalSubtitleFormat;
54
+ content?: string;
55
+ load?: () => Promise<string>;
56
+ };
36
57
  /** Shared by both arms: nothing here depends on who owns the media. */
37
58
  type CommonOptions = {
38
59
  /**
@@ -64,6 +85,8 @@ type CommonOptions = {
64
85
  autoplayNext?: boolean;
65
86
  /** The viewer flipped the switch, to `autoplayNext`: what a host saves to pass back as `autoplayNext`. */
66
87
  onAutoplayNextChange?: (autoplayNext: boolean) => void;
88
+ /** Previous and next episode navigation controls shown next to play. An embedder setting them via `expose` wins. */
89
+ episodeNavigation?: EpisodeNavigation;
67
90
  /**
68
91
  * Named spans of the timeline, drawn as segments on the seekbar.
69
92
  *
@@ -263,6 +286,11 @@ export type MediaPlayerLocalOptions = CommonOptions & MediaPlayerSource & {
263
286
  * viewer's own language is both. True, the default, starts them as `preferredSubtitleLanguage` says.
264
287
  */
265
288
  alwaysShowSubtitles?: boolean;
289
+ /**
290
+ * Sidecar subtitle tracks rendered through `SubtitleRenderer` alongside any muxed streams.
291
+ * An embedder setting tracks via `expose` wins while connected.
292
+ */
293
+ externalSubtitles?: ExternalSubtitleTrack[];
266
294
  };
267
295
  /**
268
296
  * A media the caller owns and the player only drives.
@@ -1,8 +1,8 @@
1
1
  import type { Transport } from 'osra';
2
2
  import type { MediaChapter } from '../engine';
3
3
  import type { PlayerMedia } from '../react/media';
4
- import type { Writable } from './protocol';
5
- export type { PlayerEvent, PlayerSnapshot, PlayerUpdate } from './protocol';
4
+ import type { RemoteExternalSubtitleTrack, Writable } from './protocol';
5
+ export type { PlayerEvent, PlayerSnapshot, PlayerUpdate, RemoteExternalSubtitleTrack } from './protocol';
6
6
  export { DEFAULT_PLAYER_ID, PLAYER_CHANNEL, PLAYER_EVENTS, SERVED_EVENTS } from './protocol';
7
7
  /**
8
8
  * Where a player serves from, and to whom.
@@ -63,6 +63,10 @@ export type ServedPlayer = EventTarget & {
63
63
  onHostFullscreen: (active: boolean | null) => void;
64
64
  onEndingOffered: (offered: boolean) => void;
65
65
  onAutoplayNext: (on: boolean | null) => void;
66
+ onPreviousEpisode?: (step: boolean | string | null | undefined) => void;
67
+ onNextEpisode?: (step: boolean | string | null | undefined) => void;
68
+ onExternalSubtitles?: (tracks: RemoteExternalSubtitleTrack[] | null) => void;
69
+ onProvideExternalSubtitle?: (trackId: string, content: string | null, error?: string) => void;
66
70
  };
67
71
  /**
68
72
  * Serve `media` to this document's embedder. Returns the teardown for THIS media.
@@ -123,6 +127,25 @@ export type MediaPlayerHandle = {
123
127
  * this. Nothing but a boolean is sent.
124
128
  */
125
129
  autoplayNext: boolean | null;
130
+ /**
131
+ * Previous episode control shown by the far `<MediaPlayer expose>`. `true` shows with default label,
132
+ * a string shows with that tooltip title, and `false` or `null` hides it. Clicking emits `previousrequest`.
133
+ */
134
+ previousEpisode: boolean | string | null;
135
+ /**
136
+ * Next episode control shown by the far `<MediaPlayer expose>`. `true` shows with default label,
137
+ * a string shows with that tooltip title, and `false` or `null` hides it. Clicking emits `nextrequest`.
138
+ */
139
+ nextEpisode: boolean | string | null;
140
+ /**
141
+ * External subtitle tracks offered to the far `<MediaPlayer expose>`, persisted per player id while
142
+ * any mirror listens.
143
+ */
144
+ externalSubtitles: RemoteExternalSubtitleTrack[];
145
+ /** Updates the remote external subtitle tracks on the far player. */
146
+ setExternalSubtitles: (tracks: RemoteExternalSubtitleTrack[]) => void;
147
+ /** Resolves or rejects a pending `subtitleloadrequest` emitted for `trackId`. */
148
+ provideExternalSubtitle: (trackId: string, content: string | null, error?: string) => void;
126
149
  /**
127
150
  * Settles once the far side has first answered with its state; reads before that answer the
128
151
  * empty defaults. Stays pending for as long as nobody answers, and rejects with an AbortError on
@@ -26,7 +26,10 @@ var t = [
26
26
  ], n = [
27
27
  "chapterschange",
28
28
  "fullscreenrequest",
29
- "autoplaynextchange"
29
+ "autoplaynextchange",
30
+ "previousrequest",
31
+ "nextrequest",
32
+ "subtitleloadrequest"
30
33
  ], r = [
31
34
  "currentTime",
32
35
  "volume",
@@ -107,29 +110,33 @@ var t = [
107
110
  }, y = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new Map(), x = (a) => {
108
111
  let o = a.channel ?? "banou-media-player", c = a.transport, u = `${o}|${a.origin ?? "*"}`, f = c ? y.get(c) ?? (y.set(c, /* @__PURE__ */ new Map()), y.get(c)) : b, p = f.get(u);
109
112
  if (p) return p;
110
- let m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map(), x = (e) => v.get(e) ?? v.set(e, /* @__PURE__ */ new Set()).get(e), S = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map(), w = (e) => h.get(e)?.onHostFullscreen(S.get(e)?.size ? C.get(e) ?? !1 : null), T = /* @__PURE__ */ new Map(), E = (e) => h.get(e)?.onAutoplayNext(T.get(e) ?? null), D = (e, t) => {
111
- v.get(e)?.delete(t), S.get(e)?.delete(t) && w(e), !v.get(e)?.size && T.delete(e) && E(e);
113
+ let m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map(), x = (e) => v.get(e) ?? v.set(e, /* @__PURE__ */ new Set()).get(e), S = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map(), w = (e) => h.get(e)?.onHostFullscreen(S.get(e)?.size ? C.get(e) ?? !1 : null), T = /* @__PURE__ */ new Map(), E = (e) => h.get(e)?.onAutoplayNext(T.get(e) ?? null), D = /* @__PURE__ */ new Map(), O = (e) => h.get(e)?.onPreviousEpisode?.(D.has(e) ? D.get(e) : void 0), k = /* @__PURE__ */ new Map(), A = (e) => h.get(e)?.onNextEpisode?.(k.has(e) ? k.get(e) : void 0), M = /* @__PURE__ */ new Map(), N = (e) => h.get(e)?.onExternalSubtitles?.(M.get(e) ?? null), P = (e, t) => {
114
+ v.get(e)?.delete(t), S.get(e)?.delete(t) && w(e), v.get(e)?.size || (T.delete(e) && E(e), D.delete(e) && O(e), k.delete(e) && A(e), M.delete(e) && N(e));
112
115
  try {
113
116
  t.onmessage = null, t.close();
114
117
  } catch {}
115
- }, O = (e, t, n = x(e)) => {
118
+ }, F = (e, t, n = x(e)) => {
116
119
  for (let r of [...n]) try {
117
120
  r.postMessage(t);
118
121
  } catch {
119
- D(e, r);
122
+ P(e, r);
120
123
  }
121
- }, k = (e) => {
124
+ }, I = (e) => {
122
125
  let t = m.get(e), n = h.get(e);
123
126
  return t ? l(t, n?.chapters, n?.endingOffered, n?.autoplayNext) : void 0;
124
- }, A = (e, t) => {
125
- let n = t === "fullscreenrequest" ? S.get(e) : v.get(e);
126
- if (!n?.size) return;
127
- let r = k(e);
128
- r && O(e, {
127
+ }, L = (e, t, n) => {
128
+ let r = t === "fullscreenrequest" ? S.get(e) : v.get(e);
129
+ if (!r?.size) return;
130
+ let i = I(e);
131
+ i && F(e, n ? {
129
132
  event: t,
130
- snapshot: r
131
- }, n);
132
- }, M = {
133
+ snapshot: i,
134
+ detail: n
135
+ } : {
136
+ event: t,
137
+ snapshot: i
138
+ }, r);
139
+ }, R = {
133
140
  subscribe: (e, t, n) => {
134
141
  if (typeof e != "string") throw TypeError("a player id must be a string");
135
142
  if (typeof MessagePort < "u" && !(t instanceof MessagePort)) throw TypeError("subscribe takes a MessagePort");
@@ -138,9 +145,9 @@ var t = [
138
145
  if (r.size >= g) throw RangeError("too many embedders for this player");
139
146
  r.add(t);
140
147
  let i = n?.fullscreen;
141
- typeof i == "boolean" && ((S.get(e) ?? S.set(e, /* @__PURE__ */ new Set()).get(e)).add(t), C.set(e, i), w(e)), t.onmessage = () => D(e, t), t.start?.();
142
- let a = k(e);
143
- a && O(e, {
148
+ typeof i == "boolean" && ((S.get(e) ?? S.set(e, /* @__PURE__ */ new Set()).get(e)).add(t), C.set(e, i), w(e)), t.onmessage = () => P(e, t), t.start?.();
149
+ let a = I(e);
150
+ a && F(e, {
144
151
  event: "loadstart",
145
152
  snapshot: a
146
153
  }, [t]);
@@ -160,60 +167,87 @@ var t = [
160
167
  T.set(e, n), E(e);
161
168
  return;
162
169
  }
170
+ if (t === "previousEpisode" || t === "nextEpisode") {
171
+ if (typeof n != "boolean" && typeof n != "string" && n !== null || !v.get(e)?.size) return;
172
+ t === "previousEpisode" ? (D.set(e, n), O(e)) : (k.set(e, n), A(e));
173
+ return;
174
+ }
163
175
  let i = m.get(e);
164
176
  if (i && r.includes(t)) try {
165
177
  i[t] = n;
166
178
  } catch {}
167
179
  },
180
+ setExternalSubtitles: (e, t) => {
181
+ if (typeof e != "string" || !v.get(e)?.size || !Array.isArray(t)) return;
182
+ let n = [];
183
+ for (let e of t) {
184
+ if (!e || typeof e != "object") continue;
185
+ let { id: t, language: r, label: i, format: a, content: o } = e;
186
+ typeof t == "string" && typeof r == "string" && typeof i == "string" && (a === "srt" || a === "vtt" || a === "ass") && n.push({
187
+ id: t,
188
+ language: r,
189
+ label: i,
190
+ format: a,
191
+ ...typeof o == "string" ? { content: o } : {}
192
+ });
193
+ }
194
+ M.set(e, n), N(e);
195
+ },
196
+ provideExternalSubtitle: (e, t, n, r) => {
197
+ typeof e == "string" && typeof t == "string" && v.get(e)?.size && (n === null || typeof n == "string") && (r === void 0 || typeof r == "string") && h.get(e)?.onProvideExternalSubtitle?.(t, n, r);
198
+ },
168
199
  call: async (e, t) => {
169
200
  let n = m.get(e);
170
201
  if (n && i.includes(t)) try {
171
202
  t === "play" ? await n.play() : t === "pause" ? n.pause() : n.load?.();
172
203
  } finally {
173
- A(e, "timeupdate");
204
+ L(e, "timeupdate");
174
205
  }
175
206
  }
176
- }, N = new AbortController();
177
- N.signal.addEventListener("abort", () => {
207
+ }, z = new AbortController();
208
+ z.signal.addEventListener("abort", () => {
178
209
  f.delete(u);
179
- for (let [e, t] of v) for (let n of [...t]) D(e, n);
210
+ for (let [e, t] of v) for (let n of [...t]) P(e, n);
180
211
  v.clear(), m.clear(), h.clear();
181
- }, { once: !0 }), e(M, {
212
+ }, { once: !0 }), e(R, {
182
213
  transport: a.transport ?? {
183
214
  emit: window.parent,
184
215
  receive: j(() => window.parent, a.origin)
185
216
  },
186
217
  origin: a.origin,
187
218
  key: o,
188
- unregisterSignal: N.signal
219
+ unregisterSignal: z.signal
189
220
  });
190
- let P = { serve: (e, r) => {
221
+ let B = { serve: (e, r) => {
191
222
  let i = r.id ?? "default", a = r.player, o = [...t.map((t) => [e, t]), ...a ? n.map((e) => [a, e]) : []].map(([t, n]) => [
192
223
  t,
193
224
  n,
194
- () => {
195
- m.get(i) === e && (n === "autoplaynextchange" && T.has(i) && typeof a?.autoplayNext == "boolean" && T.set(i, a.autoplayNext), A(i, n));
225
+ (t) => {
226
+ if (m.get(i) !== e) return;
227
+ n === "autoplaynextchange" && T.has(i) && typeof a?.autoplayNext == "boolean" && T.set(i, a.autoplayNext);
228
+ let r = n === "subtitleloadrequest" ? t.detail : void 0, o = r && typeof r == "object" && typeof r.trackId == "string" ? { trackId: r.trackId } : void 0;
229
+ L(i, n, o);
196
230
  }
197
231
  ]);
198
232
  for (let [e, t, n] of o) e.addEventListener(t, n);
199
233
  let c = m.has(i), l = h.get(i);
200
- l && l !== a && l.onHostFullscreen(null), m.set(i, e), a ? h.set(i, a) : h.delete(i), w(i), T.has(i) && E(i), c && O(i, {
234
+ l && l !== a && (l.onHostFullscreen(null), l.onPreviousEpisode?.(void 0), l.onNextEpisode?.(void 0), l.onExternalSubtitles?.(null)), m.set(i, e), a ? h.set(i, a) : h.delete(i), w(i), T.has(i) && E(i), D.has(i) && O(i), k.has(i) && A(i), M.has(i) && N(i), c && F(i, {
201
235
  event: "emptied",
202
236
  snapshot: { ...d }
203
237
  });
204
- for (let e of s(k(i))) A(i, e);
238
+ for (let e of s(I(i))) L(i, e);
205
239
  let u = () => {
206
240
  for (let [e, t, n] of o) e.removeEventListener(t, n);
207
- m.get(i) === e && (m.delete(i), a && h.get(i) === a && (h.delete(i), a.onHostFullscreen(null)), O(i, {
241
+ m.get(i) === e && (m.delete(i), a && h.get(i) === a && (h.delete(i), a.onHostFullscreen(null), a.onPreviousEpisode?.(void 0), a.onNextEpisode?.(void 0), a.onExternalSubtitles?.(null)), F(i, {
208
242
  event: "emptied",
209
243
  snapshot: { ...d }
210
244
  }));
211
245
  }, f = () => {
212
- u(), N.abort();
246
+ u(), z.abort();
213
247
  };
214
248
  return r.signal && (r.signal.aborted ? f() : r.signal.addEventListener("abort", f, { once: !0 })), u;
215
249
  } };
216
- return f.set(u, P), P;
250
+ return f.set(u, B), B;
217
251
  }, S = /* @__PURE__ */ new WeakMap(), C = (t, n) => {
218
252
  let r = n.channel ?? "banou-media-player", i = `${r}|${n.origin ?? "*"}`, a = S.get(t) ?? (S.set(t, /* @__PURE__ */ new Map()), S.get(t)), o = a.get(i);
219
253
  if (o) return o;
@@ -263,6 +297,8 @@ var t = [
263
297
  d(e), c.delete(e), c.size || p();
264
298
  }),
265
299
  set: (e, t, n) => u?.set(e, t, n),
300
+ setExternalSubtitles: (e, t) => u?.setExternalSubtitles?.(e, t),
301
+ provideExternalSubtitle: (e, t, n, r) => u?.provideExternalSubtitle?.(e, t, n, r),
266
302
  call: async (e, t) => {
267
303
  if (!u) throw new DOMException("the remote player was closed", "AbortError");
268
304
  await u.call(e, t);
@@ -271,38 +307,44 @@ var t = [
271
307
  return a.set(i, m), m;
272
308
  }, w = (e, t = {}) => {
273
309
  E(t.origin);
274
- let n = new AbortController(), i = t.signal ? AbortSignal.any([t.signal, n.signal]) : n.signal, a = t.id ?? "default", o = { ...d }, c = new EventTarget(), l = (e) => c.dispatchEvent(new Event(e)), u, p, g = new Promise((e, t) => {
310
+ let n = new AbortController(), i = t.signal ? AbortSignal.any([t.signal, n.signal]) : n.signal, a = t.id ?? "default", o = { ...d }, c = new EventTarget(), l = (e, t) => {
311
+ if (t !== void 0) {
312
+ c.dispatchEvent(typeof CustomEvent == "function" ? new CustomEvent(e, { detail: t }) : Object.assign(new Event(e), { detail: t }));
313
+ return;
314
+ }
315
+ c.dispatchEvent(new Event(e));
316
+ }, u, p, g = new Promise((e, t) => {
275
317
  u = e, p = t;
276
318
  });
277
319
  g.catch(() => {});
278
320
  let _ = () => new DOMException("the remote player was closed", "AbortError"), v = /* @__PURE__ */ new Set(), y = () => {
279
321
  for (let e of [...v]) e(_());
280
322
  v.clear();
281
- }, b = /* @__PURE__ */ new Map(), x = !1, S = !1, w = 0, T = /* @__PURE__ */ new Set(), D = () => {
282
- w++;
283
- for (let e of Array.from(T)) e();
284
- }, O = C(e, t).attach({
323
+ }, b = /* @__PURE__ */ new Map(), x = !1, S = !1, w = null, T = null, D = [], O = 0, k = /* @__PURE__ */ new Set(), A = () => {
324
+ O++;
325
+ for (let e of Array.from(k)) e();
326
+ }, j = C(e, t).attach({
285
327
  id: a,
286
328
  fullscreen: t.fullscreen ? () => S : void 0,
287
329
  reset: () => {
288
330
  x = !1, y();
289
331
  },
290
- update: ({ event: e, snapshot: t }) => {
291
- let n = !x;
332
+ update: ({ event: e, snapshot: t, detail: n }) => {
333
+ let r = !x;
292
334
  x = !0;
293
- let r = JSON.stringify(o.chapters), i = o.autoplayNext;
335
+ let i = JSON.stringify(o.chapters), a = o.autoplayNext;
294
336
  Object.assign(o, t);
295
337
  for (let [e, t] of b) o[e] = t;
296
- let a = n ? s(o) : [e];
297
- !a.includes("chapterschange") && JSON.stringify(o.chapters) !== r && a.push("chapterschange"), !a.includes("autoplaynextchange") && o.autoplayNext !== i && a.push("autoplaynextchange"), !n && e === "pause" && D();
298
- for (let e of a) l(e);
299
- n && u();
338
+ let c = r ? s(o) : [e];
339
+ !c.includes("chapterschange") && JSON.stringify(o.chapters) !== i && c.push("chapterschange"), !c.includes("autoplaynextchange") && o.autoplayNext !== a && c.push("autoplaynextchange"), !r && e === "pause" && A();
340
+ for (let t of c) l(t, t === e ? n : void 0);
341
+ r && u();
300
342
  }
301
- }), k = () => {
302
- O(), y(), p(_());
343
+ }), M = () => {
344
+ j(), y(), p(_());
303
345
  };
304
- i.aborted ? queueMicrotask(k) : i.addEventListener("abort", k, { once: !0 });
305
- let A = (e, t) => Object.defineProperty(c, e, {
346
+ i.aborted ? queueMicrotask(M) : i.addEventListener("abort", M, { once: !0 });
347
+ let N = (e, t) => Object.defineProperty(c, e, {
306
348
  get: () => t ? t(o[e]) : o[e],
307
349
  enumerable: !0
308
350
  });
@@ -317,14 +359,14 @@ var t = [
317
359
  "error",
318
360
  "videoWidth",
319
361
  "videoHeight"
320
- ]) A(e);
321
- A("buffered", f), A("seekable", f), A("chapters");
322
- let j = (e) => g.then(() => i.aborted ? void 0 : e()).catch(() => {}), M = C(e, t);
362
+ ]) N(e);
363
+ N("buffered", f), N("seekable", f), N("chapters");
364
+ let P = (e) => g.then(() => i.aborted ? void 0 : e()).catch(() => {}), F = C(e, t);
323
365
  for (let e of r) Object.defineProperty(c, e, {
324
366
  get: () => o[e],
325
367
  set: (t) => {
326
- o[e] = t, b.set(e, t), j(async () => {
327
- await M.set(a, e, t), b.get(e) === t && b.delete(e);
368
+ o[e] = t, b.set(e, t), P(async () => {
369
+ await F.set(a, e, t), b.get(e) === t && b.delete(e);
328
370
  });
329
371
  },
330
372
  enumerable: !0
@@ -332,25 +374,49 @@ var t = [
332
374
  Object.defineProperty(c, "fullscreen", {
333
375
  get: () => S,
334
376
  set: (e) => {
335
- S = !!e, t.fullscreen && j(() => M.set(a, "fullscreen", S));
377
+ S = !!e, t.fullscreen && P(() => F.set(a, "fullscreen", S));
336
378
  },
337
379
  enumerable: !0
338
380
  }), Object.defineProperty(c, "endingOffered", {
339
381
  get: () => o.endingOffered,
340
382
  set: (e) => {
341
- j(() => M.set(a, "endingOffered", e));
383
+ P(() => F.set(a, "endingOffered", e));
342
384
  },
343
385
  enumerable: !0
344
386
  }), Object.defineProperty(c, "autoplayNext", {
345
387
  get: () => o.autoplayNext,
346
388
  set: (e) => {
347
- typeof e == "boolean" && j(() => M.set(a, "autoplayNext", e));
389
+ typeof e == "boolean" && P(() => F.set(a, "autoplayNext", e));
390
+ },
391
+ enumerable: !0
392
+ }), Object.defineProperty(c, "previousEpisode", {
393
+ get: () => w,
394
+ set: (e) => {
395
+ (typeof e == "boolean" || typeof e == "string" || e === null) && (w = e, P(() => F.set(a, "previousEpisode", e)));
396
+ },
397
+ enumerable: !0
398
+ }), Object.defineProperty(c, "nextEpisode", {
399
+ get: () => T,
400
+ set: (e) => {
401
+ (typeof e == "boolean" || typeof e == "string" || e === null) && (T = e, P(() => F.set(a, "nextEpisode", e)));
348
402
  },
349
403
  enumerable: !0
350
404
  });
351
- let N = (e) => g.then(() => {
405
+ let I = (e) => {
406
+ if (!Array.isArray(e)) return;
407
+ let t = e.map((e) => ({ ...e }));
408
+ D = t, P(() => F.setExternalSubtitles(a, t));
409
+ };
410
+ Object.defineProperty(c, "externalSubtitles", {
411
+ get: () => D,
412
+ set: I,
413
+ enumerable: !0
414
+ }), c.setExternalSubtitles = I, c.provideExternalSubtitle = (e, t, n) => {
415
+ P(() => F.provideExternalSubtitle(a, e, t, n));
416
+ };
417
+ let L = (e) => g.then(() => {
352
418
  if (i.aborted) throw _();
353
- let t = M.call(a, e);
419
+ let t = F.call(a, e);
354
420
  return new Promise((e, n) => {
355
421
  v.add(n), t.then(() => {
356
422
  v.delete(n), e();
@@ -359,12 +425,12 @@ var t = [
359
425
  });
360
426
  });
361
427
  });
362
- c.play = () => (o.paused = !1, N("play").catch((e) => {
428
+ c.play = () => (o.paused = !1, L("play").catch((e) => {
363
429
  throw o.paused = !0, e;
364
430
  }));
365
- let P = async () => {
366
- let e = !o.paused, t = w, n = !1, r, a, s, l, u, d = () => {
367
- s && (c.removeEventListener("playing", s), c.removeEventListener("play", s)), l && T.delete(l), u && i.removeEventListener("abort", u);
431
+ let R = async () => {
432
+ let e = !o.paused, t = O, n = !1, r, a, s, l, u, d = () => {
433
+ s && (c.removeEventListener("playing", s), c.removeEventListener("play", s)), l && k.delete(l), u && i.removeEventListener("abort", u);
368
434
  };
369
435
  e || (a = new Promise((e) => {
370
436
  r = (t) => {
@@ -372,7 +438,7 @@ var t = [
372
438
  };
373
439
  }), s = () => {
374
440
  n = !0, r?.(!0);
375
- }, l = () => r?.(!1), u = () => r?.(!1), c.addEventListener("playing", s), c.addEventListener("play", s), T.add(l), i.addEventListener("abort", u, { once: !0 }));
441
+ }, l = () => r?.(!1), u = () => r?.(!1), c.addEventListener("playing", s), c.addEventListener("play", s), k.add(l), i.addEventListener("abort", u, { once: !0 }));
376
442
  let f;
377
443
  try {
378
444
  await c.play();
@@ -384,7 +450,7 @@ var t = [
384
450
  paused: !1,
385
451
  refusal: f
386
452
  };
387
- let p = () => w !== t;
453
+ let p = () => O !== t;
388
454
  if (n || p() || i.aborted) return d(), {
389
455
  started: n && !p(),
390
456
  paused: p(),
@@ -402,17 +468,17 @@ var t = [
402
468
  }
403
469
  };
404
470
  return c.autoplay = async () => {
405
- let e = w, t = await P();
471
+ let e = O, t = await R();
406
472
  if (t.started) return { muted: c.muted };
407
- if (t.paused || w !== e || c.muted || i.aborted) throw t.refusal ?? h();
473
+ if (t.paused || O !== e || c.muted || i.aborted) throw t.refusal ?? h();
408
474
  c.muted = !0;
409
- let n = await P();
475
+ let n = await R();
410
476
  if (n.started) return { muted: !0 };
411
477
  throw c.muted = !1, t.refusal ?? n.refusal ?? h();
412
478
  }, c.pause = () => {
413
- o.paused = !0, D(), N("pause").catch(() => {});
479
+ o.paused = !0, A(), L("pause").catch(() => {});
414
480
  }, c.load = () => {
415
- N("load").catch(() => {});
481
+ L("load").catch(() => {});
416
482
  }, Object.defineProperty(c, "ready", {
417
483
  value: g,
418
484
  enumerable: !1