@banou/media-player 0.10.40 → 0.10.41

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 (72) hide show
  1. package/README.md +13 -0
  2. package/dist/{ar-CS4Yzfxw.js → ar-CWVutin3.js} +1 -0
  3. package/dist/{cs-CxBZ1aTx.js → cs-CmwRGxyE.js} +1 -0
  4. package/dist/{de-DphEdq0O.js → de-DLdKEf3t.js} +1 -0
  5. package/dist/{el-BVTNfAWK.js → el-Ckj-z6DX.js} +1 -0
  6. package/dist/engine/index.js +1 -1
  7. package/dist/{engine-DFqSQyNb.js → engine-wP5Udzzj.js} +1 -0
  8. package/dist/{es-419-D6gsvnn8.js → es-419-zORhhU8D.js} +1 -0
  9. package/dist/{fr-BqAzAJX0.js → fr-BtPmNkri.js} +1 -0
  10. package/dist/{he-DbFw1CdO.js → he-Bu79qEth.js} +1 -0
  11. package/dist/{hi-rBroV7g8.js → hi-BsH3tSHa.js} +1 -0
  12. package/dist/{hu-m-QKaaxF.js → hu-BkYBW-YP.js} +1 -0
  13. package/dist/{id-BYpApdK9.js → id-nUaBCV4o.js} +1 -0
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.js +263 -236
  16. package/dist/{it-NTcUh3Gr.js → it-CqPSHyFA.js} +1 -0
  17. package/dist/{ja-DSmX_bxj.js → ja-DTjvriHw.js} +1 -0
  18. package/dist/{ko-DyPzWasj.js → ko-dV8T7XOJ.js} +1 -0
  19. package/dist/labels.d.ts +1 -0
  20. package/dist/{ms-8pQbqM0D.js → ms-VZQ7BI0z.js} +1 -0
  21. package/dist/{nl-q7xvc3xW.js → nl-Q6iDxbDz.js} +1 -0
  22. package/dist/{pl-C6Ow4ra5.js → pl-BN7bK74l.js} +1 -0
  23. package/dist/{pt-BR-wudK3giz.js → pt-BR-CPFILeFW.js} +1 -0
  24. package/dist/react/player.d.ts +1 -0
  25. package/dist/react/source-feature.d.ts +9 -0
  26. package/dist/react/video-player.d.ts +9 -0
  27. package/dist/remote/index.d.ts +18 -0
  28. package/dist/remote/index.js +51 -34
  29. package/dist/remote/protocol.d.ts +11 -6
  30. package/dist/{ro-DBrd08Df.js → ro-Bwcm-i3k.js} +1 -0
  31. package/dist/{ru-D5kxBkik.js → ru-D1FMz751.js} +1 -0
  32. package/dist/{sv-DJC3tXfW.js → sv-ci9K0Lkk.js} +1 -0
  33. package/dist/{th-BNzU_FYo.js → th-DR-UBONQ.js} +1 -0
  34. package/dist/{tr-CW7R7N9k.js → tr-BqhdfT22.js} +1 -0
  35. package/dist/{uk-C66esN2W.js → uk-8pkZqdni.js} +1 -0
  36. package/dist/{vi-oOaDECwu.js → vi-3mKZ9G_M.js} +1 -0
  37. package/dist/{zh-Hans-IhL1Pl78.js → zh-Hans-CDgigWKY.js} +1 -0
  38. package/dist/{zh-Hant-C5YyFjEc.js → zh-Hant-3WSNI0ne.js} +1 -0
  39. package/package.json +1 -1
  40. package/src/lib/index.tsx +2 -1
  41. package/src/lib/labels.ts +1 -0
  42. package/src/lib/locales/ar.json +1 -0
  43. package/src/lib/locales/cs.json +1 -0
  44. package/src/lib/locales/de.json +1 -0
  45. package/src/lib/locales/el.json +1 -0
  46. package/src/lib/locales/es-419.json +1 -0
  47. package/src/lib/locales/fr.json +1 -0
  48. package/src/lib/locales/he.json +1 -0
  49. package/src/lib/locales/hi.json +1 -0
  50. package/src/lib/locales/hu.json +1 -0
  51. package/src/lib/locales/id.json +1 -0
  52. package/src/lib/locales/it.json +1 -0
  53. package/src/lib/locales/ja.json +1 -0
  54. package/src/lib/locales/ko.json +1 -0
  55. package/src/lib/locales/ms.json +1 -0
  56. package/src/lib/locales/nl.json +1 -0
  57. package/src/lib/locales/pl.json +1 -0
  58. package/src/lib/locales/pt-BR.json +1 -0
  59. package/src/lib/locales/ro.json +1 -0
  60. package/src/lib/locales/ru.json +1 -0
  61. package/src/lib/locales/sv.json +1 -0
  62. package/src/lib/locales/th.json +1 -0
  63. package/src/lib/locales/tr.json +1 -0
  64. package/src/lib/locales/uk.json +1 -0
  65. package/src/lib/locales/vi.json +1 -0
  66. package/src/lib/locales/zh-Hans.json +1 -0
  67. package/src/lib/locales/zh-Hant.json +1 -0
  68. package/src/lib/react/components/settings.tsx +19 -0
  69. package/src/lib/react/source-feature.ts +10 -0
  70. package/src/lib/react/video-player.tsx +40 -1
  71. package/src/lib/remote/index.ts +48 -3
  72. package/src/lib/remote/protocol.ts +18 -6
@@ -2,6 +2,7 @@
2
2
  var e = "Audio", t = "Copiato", n = "Copia", r = "Disattivati", i = "Disattiva audio", a = "Pausa", o = "Riproduci", s = "Qualità", c = "Guarda di nuovo", l = "Impostazioni", u = "Sottotitoli", d = "Non disponibile", f = "ripristinato", p = {
3
3
  "(Default)": "(Normale)",
4
4
  Audio: e,
5
+ "Autoplay next episode": "Riproduzione automatica dell’episodio successivo",
5
6
  Copied: t,
6
7
  Copy: n,
7
8
  "Copy the errors": "Copia gli errori",
@@ -2,6 +2,7 @@
2
2
  var e = "音声", t = "コピーしました", n = "コピー", r = "オフ", i = "ミュート", a = "一時停止", o = "再生", s = "画質", c = "もう一度再生", l = "設定", u = "字幕", d = "利用できません", f = "復旧済み", p = {
3
3
  "(Default)": "(標準)",
4
4
  Audio: e,
5
+ "Autoplay next episode": "次のエピソードを自動再生",
5
6
  Copied: t,
6
7
  Copy: n,
7
8
  "Copy the errors": "エラーをコピー",
@@ -2,6 +2,7 @@
2
2
  var e = "오디오", t = "복사됨", n = "복사", r = "사용 안함", i = "음소거", a = "일시정지", o = "재생", s = "화질", c = "다시 보기", l = "설정", u = "자막", d = "사용할 수 없음", f = "복구됨", p = {
3
3
  "(Default)": "(보통)",
4
4
  Audio: e,
5
+ "Autoplay next episode": "다음 에피소드 자동 재생",
5
6
  Copied: t,
6
7
  Copy: n,
7
8
  "Copy the errors": "오류 복사",
package/dist/labels.d.ts CHANGED
@@ -33,6 +33,7 @@ export declare const LABELS: {
33
33
  readonly defaultSpeed: '(Default)';
34
34
  readonly speed: '{rate}x';
35
35
  readonly normalizeVolume: 'Normalize volume';
36
+ readonly autoplayNext: 'Autoplay next episode';
36
37
  readonly unavailable: 'Unavailable';
37
38
  readonly switchFailed: 'Could not switch. Try again.';
38
39
  readonly track: 'Track {number}';
@@ -2,6 +2,7 @@
2
2
  var e = "Audio", t = "Disalin", n = "Salin", r = "Mati", i = "Redam", a = "Jeda", o = "Main", s = "Kualiti", c = "Main semula", l = "Tetapan", u = "Sari kata", d = "Tidak tersedia", f = "dipulihkan", p = {
3
3
  "(Default)": "(Biasa)",
4
4
  Audio: e,
5
+ "Autoplay next episode": "Main episod seterusnya secara automatik",
5
6
  Copied: t,
6
7
  Copy: n,
7
8
  "Copy the errors": "Salin ralat",
@@ -2,6 +2,7 @@
2
2
  var e = "Audio", t = "Gekopieerd", n = "Kopiëren", r = "Uit", i = "Dempen", a = "Pauzeren", o = "Afspelen", s = "Kwaliteit", c = "Opnieuw afspelen", l = "Instellingen", u = "Ondertitels", d = "Niet beschikbaar", f = "hersteld", p = {
3
3
  "(Default)": "(Normaal)",
4
4
  Audio: e,
5
+ "Autoplay next episode": "Volgende aflevering automatisch afspelen",
5
6
  Copied: t,
6
7
  Copy: n,
7
8
  "Copy the errors": "Fouten kopiëren",
@@ -2,6 +2,7 @@
2
2
  var e = "Dźwięk", t = "Skopiowano", n = "Kopiuj", r = "Wyłączone", i = "Wycisz", a = "Wstrzymaj", o = "Odtwórz", s = "Jakość", c = "Odtwórz ponownie", l = "Ustawienia", u = "Napisy", d = "Niedostępne", f = "naprawiono", p = {
3
3
  "(Default)": "(Normalna)",
4
4
  Audio: e,
5
+ "Autoplay next episode": "Automatyczne odtwarzanie następnego odcinka",
5
6
  Copied: t,
6
7
  Copy: n,
7
8
  "Copy the errors": "Kopiuj błędy",
@@ -2,6 +2,7 @@
2
2
  var e = "Áudio", t = "Copiado", n = "Copiar", r = "Desativadas", i = "Desativar som", a = "Pausar", o = "Reproduzir", s = "Qualidade", c = "Assistir de novo", l = "Configurações", u = "Legendas", d = "Indisponível", f = "recuperado", p = {
3
3
  "(Default)": "(Normal)",
4
4
  Audio: e,
5
+ "Autoplay next episode": "Reprodução automática do próximo episódio",
5
6
  Copied: t,
6
7
  Copy: n,
7
8
  "Copy the errors": "Copiar os erros",
@@ -24,6 +24,7 @@ export declare const Player: import("@videojs/react").CreatePlayerResult<import(
24
24
  pictureInPictureMode: import("../engine").PictureInPictureMode | null;
25
25
  burnedInSubtitles: boolean;
26
26
  volumeNormalizer: import("./source-feature").VolumeNormalizerControl | null;
27
+ autoplayNext: import("./source-feature").AutoplayNextControl | null;
27
28
  requestSeek?: (time: number) => void;
28
29
  stepFrame?: (direction: 1 | -1) => void;
29
30
  playbackError: unknown;
@@ -98,6 +98,11 @@ export type VolumeNormalizerControl = {
98
98
  available: boolean;
99
99
  setEnabled: (enabled: boolean) => void;
100
100
  };
101
+ /** The settings menu's "Autoplay next episode" switch, for a host or an embedder that offers one (see `autoplayNext`). */
102
+ export type AutoplayNextControl = {
103
+ enabled: boolean;
104
+ setEnabled: (enabled: boolean) => void;
105
+ };
101
106
  /**
102
107
  * Everything about the source that the chrome reads, carried on the player store next to the built-in
103
108
  * playback state so a component never has to know which of two channels owns a field.
@@ -206,6 +211,8 @@ export type SourceState = {
206
211
  burnedInSubtitles: boolean;
207
212
  /** null when the player offers no volume normalizer: a media it does not own, or no `normalizerWorkletUrl`. */
208
213
  volumeNormalizer: VolumeNormalizerControl | null;
214
+ /** null when neither the host nor an embedder offers the switch. */
215
+ autoplayNext: AutoplayNextControl | null;
209
216
  /**
210
217
  * Move the playhead, letting the pipeline get the data there first.
211
218
  *
@@ -358,6 +365,8 @@ export declare const sourceFeature: import("@videojs/react").PlayerFeature<{
358
365
  burnedInSubtitles: boolean;
359
366
  /** null when the player offers no volume normalizer: a media it does not own, or no `normalizerWorkletUrl`. */
360
367
  volumeNormalizer: VolumeNormalizerControl | null;
368
+ /** null when neither the host nor an embedder offers the switch. */
369
+ autoplayNext: AutoplayNextControl | null;
361
370
  /**
362
371
  * Move the playhead, letting the pipeline get the data there first.
363
372
  *
@@ -55,6 +55,15 @@ type CommonOptions = {
55
55
  */
56
56
  title?: string;
57
57
  autoplay?: boolean;
58
+ /**
59
+ * The settings menu's "Autoplay next episode" switch, for a host that plays the next episode itself: the player plays
60
+ * nothing next. Without it, and with no embedder setting it through `expose`, there is no switch. The player keeps the
61
+ * switch's state from here and from the viewer's clicks; nothing is saved, so a host that wants it to stick saves
62
+ * what `onAutoplayNextChange` reports and passes it back. A value an embedder sets wins over this one.
63
+ */
64
+ autoplayNext?: boolean;
65
+ /** The viewer flipped the switch, to `autoplayNext`: what a host saves to pass back as `autoplayNext`. */
66
+ onAutoplayNextChange?: (autoplayNext: boolean) => void;
58
67
  /**
59
68
  * Named spans of the timeline, drawn as segments on the seekbar.
60
69
  *
@@ -51,12 +51,18 @@ export type ExposePlayerOptions = {
51
51
  * with `fullscreen: true` takes over. While one has it, `onHostFullscreen` is told the state that mirror sets, and null
52
52
  * once none has it; the player then dispatches `fullscreenrequest` for each press of its fullscreen, which reaches the
53
53
  * mirror. `onEndingOffered` is told what a mirror sets on `endingOffered`.
54
+ *
55
+ * `autoplayNext` is the state of its "Autoplay next episode" switch, null while it shows none, and it raises
56
+ * `autoplaynextchange` after each change. `onAutoplayNext` is told the state a mirror last set for its id, at serve
57
+ * and on each write, and null once no mirror listens to the id any more.
54
58
  */
55
59
  export type ServedPlayer = EventTarget & {
56
60
  readonly chapters: MediaChapter[];
57
61
  readonly endingOffered: boolean;
62
+ readonly autoplayNext: boolean | null;
58
63
  onHostFullscreen: (active: boolean | null) => void;
59
64
  onEndingOffered: (offered: boolean) => void;
65
+ onAutoplayNext: (on: boolean | null) => void;
60
66
  };
61
67
  /**
62
68
  * Serve `media` to this document's embedder. Returns the teardown for THIS media.
@@ -105,6 +111,18 @@ export type MediaPlayerHandle = {
105
111
  * off the far screen, and a player that cannot take it (a bare element, a version older than this) stays true.
106
112
  */
107
113
  endingOffered: boolean;
114
+ /**
115
+ * The far `<MediaPlayer expose>`'s "Autoplay next episode" switch, as it last said: null while it shows none. Set a
116
+ * boolean to have it show the switch in that state, for a page that plays the next episode itself and keeps the
117
+ * setting; the player plays nothing next and saves nothing. The far document keeps what was set for this player's
118
+ * id while any mirror of it is open, and shows it on every player it serves under that id, so a page that puts up
119
+ * a player per file needs to set it once. A viewer's flip there is kept the same way.
120
+ *
121
+ * Like `endingOffered`, a write does NOT move the mirror: a read answers what the far player reports, with an
122
+ * `autoplaynextchange` event following each change, so it stays null for a bare element or a version older than
123
+ * this. Nothing but a boolean is sent.
124
+ */
125
+ autoplayNext: boolean | null;
108
126
  /**
109
127
  * Settles once the far side has first answered with its state; reads before that answer the
110
128
  * empty defaults. Stays pending for as long as nobody answers, and rejects with an AbortError on
@@ -23,7 +23,11 @@ var t = [
23
23
  "emptied",
24
24
  "resize",
25
25
  "error"
26
- ], n = ["chapterschange", "fullscreenrequest"], r = [
26
+ ], n = [
27
+ "chapterschange",
28
+ "fullscreenrequest",
29
+ "autoplaynextchange"
30
+ ], r = [
27
31
  "currentTime",
28
32
  "volume",
29
33
  "muted",
@@ -49,7 +53,7 @@ var t = [
49
53
  let t = [];
50
54
  for (let n = 0; n < e.length; n++) t.push([e.start(n), e.end(n)]);
51
55
  return t;
52
- }, l = (e, t = [], n = !0) => ({
56
+ }, l = (e, t = [], n = !0, r = null) => ({
53
57
  currentTime: u(e.currentTime),
54
58
  duration: u(e.duration),
55
59
  paused: e.paused,
@@ -70,7 +74,8 @@ var t = [
70
74
  videoWidth: e.videoWidth ?? 0,
71
75
  videoHeight: e.videoHeight ?? 0,
72
76
  chapters: t,
73
- endingOffered: n
77
+ endingOffered: n,
78
+ autoplayNext: r
74
79
  }), u = (e) => Number.isNaN(e) ? 0 : e, d = {
75
80
  currentTime: 0,
76
81
  duration: 0,
@@ -89,7 +94,8 @@ var t = [
89
94
  videoWidth: 0,
90
95
  videoHeight: 0,
91
96
  chapters: [],
92
- endingOffered: !0
97
+ endingOffered: !0,
98
+ autoplayNext: null
93
99
  }, f = (e) => ({
94
100
  length: e.length,
95
101
  start: (t) => e[t]?.[0] ?? 0,
@@ -101,29 +107,29 @@ var t = [
101
107
  }, y = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new Map(), x = (a) => {
102
108
  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);
103
109
  if (p) return p;
104
- 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 = (e, t) => {
105
- v.get(e)?.delete(t), S.get(e)?.delete(t) && w(e);
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);
106
112
  try {
107
113
  t.onmessage = null, t.close();
108
114
  } catch {}
109
- }, E = (e, t, n = x(e)) => {
115
+ }, O = (e, t, n = x(e)) => {
110
116
  for (let r of [...n]) try {
111
117
  r.postMessage(t);
112
118
  } catch {
113
- T(e, r);
119
+ D(e, r);
114
120
  }
115
- }, D = (e) => {
121
+ }, k = (e) => {
116
122
  let t = m.get(e), n = h.get(e);
117
- return t ? l(t, n?.chapters, n?.endingOffered) : void 0;
118
- }, O = (e, t) => {
123
+ return t ? l(t, n?.chapters, n?.endingOffered, n?.autoplayNext) : void 0;
124
+ }, A = (e, t) => {
119
125
  let n = t === "fullscreenrequest" ? S.get(e) : v.get(e);
120
126
  if (!n?.size) return;
121
- let r = D(e);
122
- r && E(e, {
127
+ let r = k(e);
128
+ r && O(e, {
123
129
  event: t,
124
130
  snapshot: r
125
131
  }, n);
126
- }, k = {
132
+ }, M = {
127
133
  subscribe: (e, t, n) => {
128
134
  if (typeof e != "string") throw TypeError("a player id must be a string");
129
135
  if (typeof MessagePort < "u" && !(t instanceof MessagePort)) throw TypeError("subscribe takes a MessagePort");
@@ -132,9 +138,9 @@ var t = [
132
138
  if (r.size >= g) throw RangeError("too many embedders for this player");
133
139
  r.add(t);
134
140
  let i = n?.fullscreen;
135
- typeof i == "boolean" && ((S.get(e) ?? S.set(e, /* @__PURE__ */ new Set()).get(e)).add(t), C.set(e, i), w(e)), t.onmessage = () => T(e, t), t.start?.();
136
- let a = D(e);
137
- a && E(e, {
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, {
138
144
  event: "loadstart",
139
145
  snapshot: a
140
146
  }, [t]);
@@ -149,6 +155,11 @@ var t = [
149
155
  typeof n == "boolean" && h.get(e)?.onEndingOffered(n);
150
156
  return;
151
157
  }
158
+ if (t === "autoplayNext") {
159
+ if (typeof n != "boolean" || !v.get(e)?.size) return;
160
+ T.set(e, n), E(e);
161
+ return;
162
+ }
152
163
  let i = m.get(e);
153
164
  if (i && r.includes(t)) try {
154
165
  i[t] = n;
@@ -159,50 +170,50 @@ var t = [
159
170
  if (n && i.includes(t)) try {
160
171
  t === "play" ? await n.play() : t === "pause" ? n.pause() : n.load?.();
161
172
  } finally {
162
- O(e, "timeupdate");
173
+ A(e, "timeupdate");
163
174
  }
164
175
  }
165
- }, A = new AbortController();
166
- A.signal.addEventListener("abort", () => {
176
+ }, N = new AbortController();
177
+ N.signal.addEventListener("abort", () => {
167
178
  f.delete(u);
168
- for (let [e, t] of v) for (let n of [...t]) T(e, n);
179
+ for (let [e, t] of v) for (let n of [...t]) D(e, n);
169
180
  v.clear(), m.clear(), h.clear();
170
- }, { once: !0 }), e(k, {
181
+ }, { once: !0 }), e(M, {
171
182
  transport: a.transport ?? {
172
183
  emit: window.parent,
173
184
  receive: j(() => window.parent, a.origin)
174
185
  },
175
186
  origin: a.origin,
176
187
  key: o,
177
- unregisterSignal: A.signal
188
+ unregisterSignal: N.signal
178
189
  });
179
- let M = { serve: (e, r) => {
190
+ let P = { serve: (e, r) => {
180
191
  let i = r.id ?? "default", a = r.player, o = [...t.map((t) => [e, t]), ...a ? n.map((e) => [a, e]) : []].map(([t, n]) => [
181
192
  t,
182
193
  n,
183
194
  () => {
184
- m.get(i) === e && O(i, n);
195
+ m.get(i) === e && (n === "autoplaynextchange" && T.has(i) && typeof a?.autoplayNext == "boolean" && T.set(i, a.autoplayNext), A(i, n));
185
196
  }
186
197
  ]);
187
198
  for (let [e, t, n] of o) e.addEventListener(t, n);
188
199
  let c = m.has(i), l = h.get(i);
189
- l && l !== a && l.onHostFullscreen(null), m.set(i, e), a ? h.set(i, a) : h.delete(i), w(i), c && E(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, {
190
201
  event: "emptied",
191
202
  snapshot: { ...d }
192
203
  });
193
- for (let e of s(D(i))) O(i, e);
204
+ for (let e of s(k(i))) A(i, e);
194
205
  let u = () => {
195
206
  for (let [e, t, n] of o) e.removeEventListener(t, n);
196
- m.get(i) === e && (m.delete(i), a && h.get(i) === a && (h.delete(i), a.onHostFullscreen(null)), E(i, {
207
+ m.get(i) === e && (m.delete(i), a && h.get(i) === a && (h.delete(i), a.onHostFullscreen(null)), O(i, {
197
208
  event: "emptied",
198
209
  snapshot: { ...d }
199
210
  }));
200
211
  }, f = () => {
201
- u(), A.abort();
212
+ u(), N.abort();
202
213
  };
203
214
  return r.signal && (r.signal.aborted ? f() : r.signal.addEventListener("abort", f, { once: !0 })), u;
204
215
  } };
205
- return f.set(u, M), M;
216
+ return f.set(u, P), P;
206
217
  }, S = /* @__PURE__ */ new WeakMap(), C = (t, n) => {
207
218
  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);
208
219
  if (o) return o;
@@ -276,12 +287,12 @@ var t = [
276
287
  update: ({ event: e, snapshot: t }) => {
277
288
  let n = !x;
278
289
  x = !0;
279
- let r = JSON.stringify(o.chapters);
290
+ let r = JSON.stringify(o.chapters), i = o.autoplayNext;
280
291
  Object.assign(o, t);
281
292
  for (let [e, t] of b) o[e] = t;
282
- let i = n ? s(o) : [e];
283
- !i.includes("chapterschange") && JSON.stringify(o.chapters) !== r && i.push("chapterschange");
284
- for (let e of i) l(e);
293
+ let a = n ? s(o) : [e];
294
+ !a.includes("chapterschange") && JSON.stringify(o.chapters) !== r && a.push("chapterschange"), !a.includes("autoplaynextchange") && o.autoplayNext !== i && a.push("autoplaynextchange");
295
+ for (let e of a) l(e);
285
296
  n && u();
286
297
  }
287
298
  }), T = () => {
@@ -327,6 +338,12 @@ var t = [
327
338
  O(() => k.set(a, "endingOffered", e));
328
339
  },
329
340
  enumerable: !0
341
+ }), Object.defineProperty(c, "autoplayNext", {
342
+ get: () => o.autoplayNext,
343
+ set: (e) => {
344
+ typeof e == "boolean" && O(() => k.set(a, "autoplayNext", e));
345
+ },
346
+ enumerable: !0
330
347
  });
331
348
  let A = (e) => g.then(() => {
332
349
  if (i.aborted) throw _();
@@ -32,6 +32,8 @@ export type PlayerSnapshot = {
32
32
  chapters: MediaChapter[];
33
33
  /** Whether a `<MediaPlayer expose>` offers to skip its last ending. Set after its render, so false means the offer is off the screen. */
34
34
  endingOffered: boolean;
35
+ /** The state of a `<MediaPlayer expose>`'s "Autoplay next episode" switch, null while it shows none or for a bare element. */
36
+ autoplayNext: boolean | null;
35
37
  };
36
38
  /**
37
39
  * The events a player raises that an embedder can hear, each carrying a fresh snapshot.
@@ -41,10 +43,10 @@ export type PlayerSnapshot = {
41
43
  */
42
44
  export declare const PLAYER_EVENTS: readonly ['loadstart', 'loadedmetadata', 'loadeddata', 'durationchange', 'timeupdate', 'play', 'playing', 'pause', 'seeking', 'seeked', 'progress', 'ratechange', 'volumechange', 'ended', 'waiting', 'stalled', 'suspend', 'canplay', 'canplaythrough', 'emptied', 'resize', 'error'];
43
45
  /**
44
- * The events a `<MediaPlayer expose>` raises beside its media's: its chapters changed, and its viewer pressed
45
- * fullscreen while a mirror made with `fullscreen: true` has it.
46
+ * The events a `<MediaPlayer expose>` raises beside its media's: its chapters changed, its viewer pressed
47
+ * fullscreen while a mirror made with `fullscreen: true` has it, and its autoplay switch changed.
46
48
  */
47
- export declare const SERVED_EVENTS: readonly ['chapterschange', 'fullscreenrequest'];
49
+ export declare const SERVED_EVENTS: readonly ['chapterschange', 'fullscreenrequest', 'autoplaynextchange'];
48
50
  export type PlayerEvent = typeof PLAYER_EVENTS[number] | typeof SERVED_EVENTS[number];
49
51
  /** The properties an embedder may set. Everything else is read-only on a media, here as there. */
50
52
  export declare const WRITABLE: readonly ['currentTime', 'volume', 'muted', 'playbackRate'];
@@ -87,8 +89,11 @@ export type PlayerService = {
87
89
  subscribe: (id: string, port: MessagePort, options?: {
88
90
  fullscreen?: boolean;
89
91
  }) => void;
90
- /** `fullscreen` is the state shown by a player whose fullscreen a mirror has taken over, and is ignored otherwise. */
91
- set: (id: string, name: Writable | 'fullscreen' | 'endingOffered', value: number | boolean) => void;
92
+ /**
93
+ * `fullscreen` is the state shown by a player whose fullscreen a mirror has taken over, and is ignored otherwise.
94
+ * `autoplayNext` is kept for the id while a mirror listens to it, and told to each player served under it.
95
+ */
96
+ set: (id: string, name: Writable | 'fullscreen' | 'endingOffered' | 'autoplayNext', value: number | boolean) => void;
92
97
  call: (id: string, name: Callable) => Promise<void>;
93
98
  };
94
99
  /**
@@ -98,7 +103,7 @@ export type PlayerService = {
98
103
  */
99
104
  export declare const syncEventsFor: (snapshot: PlayerSnapshot) => PlayerEvent[];
100
105
  /** A media as a snapshot. A NaN duration, which a bare element answers before it has metadata, is sent as 0. */
101
- export declare const snapshotOf: (media: PlayerMedia, chapters?: MediaChapter[], endingOffered?: boolean) => PlayerSnapshot;
106
+ export declare const snapshotOf: (media: PlayerMedia, chapters?: MediaChapter[], endingOffered?: boolean, autoplayNext?: boolean | null) => PlayerSnapshot;
102
107
  /** The snapshot an embedder holds before the player's document has said anything. */
103
108
  export declare const EMPTY_SNAPSHOT: PlayerSnapshot;
104
109
  /** Plain pairs back into the structural `TimeRanges` the player reads. */
@@ -2,6 +2,7 @@
2
2
  var e = "Audio", t = "S-a copiat", n = "Copiați", r = "Dezactivate", i = "Dezactivați sunetul", a = "Întrerupeți", o = "Redați", s = "Calitate", c = "Redați din nou", l = "Setări", u = "Subtitrări", d = "Indisponibil", f = "restabilit", p = {
3
3
  "(Default)": "(Normală)",
4
4
  Audio: e,
5
+ "Autoplay next episode": "Redare automată a episodului următor",
5
6
  Copied: t,
6
7
  Copy: n,
7
8
  "Copy the errors": "Copiați erorile",
@@ -2,6 +2,7 @@
2
2
  var e = "Аудио", t = "Скопировано", n = "Копировать", r = "Выключены", i = "Выключить звук", a = "Пауза", o = "Воспроизвести", s = "Качество", c = "Смотреть снова", l = "Настройки", u = "Субтитры", d = "Недоступно", f = "восстановлено", p = {
3
3
  "(Default)": "(Обычная)",
4
4
  Audio: e,
5
+ "Autoplay next episode": "Автовоспроизведение следующей серии",
5
6
  Copied: t,
6
7
  Copy: n,
7
8
  "Copy the errors": "Копировать ошибки",
@@ -2,6 +2,7 @@
2
2
  var e = "Ljud", t = "Kopierat", n = "Kopiera", r = "Av", i = "Stäng av ljudet", a = "Pausa", o = "Spela upp", s = "Kvalitet", c = "Spela igen", l = "Inställningar", u = "Undertexter", d = "Inte tillgängligt", f = "återställt", p = {
3
3
  "(Default)": "(Normal)",
4
4
  Audio: e,
5
+ "Autoplay next episode": "Spela upp nästa avsnitt automatiskt",
5
6
  Copied: t,
6
7
  Copy: n,
7
8
  "Copy the errors": "Kopiera felen",
@@ -2,6 +2,7 @@
2
2
  var e = "เสียง", t = "คัดลอกแล้ว", n = "คัดลอก", r = "ปิด", i = "ปิดเสียง", a = "หยุดชั่วคราว", o = "เล่น", s = "คุณภาพ", c = "เล่นอีกครั้ง", l = "การตั้งค่า", u = "คำบรรยาย", d = "ไม่พร้อมใช้งาน", f = "กู้คืนแล้ว", p = {
3
3
  "(Default)": "(ปกติ)",
4
4
  Audio: e,
5
+ "Autoplay next episode": "เล่นตอนถัดไปอัตโนมัติ",
5
6
  Copied: t,
6
7
  Copy: n,
7
8
  "Copy the errors": "คัดลอกข้อผิดพลาด",
@@ -2,6 +2,7 @@
2
2
  var e = "Ses", t = "Kopyalandı", n = "Kopyala", r = "Kapalı", i = "Sesi kapat", a = "Duraklat", o = "Oynat", s = "Kalite", c = "Tekrar oynat", l = "Ayarlar", u = "Altyazılar", d = "Kullanılamıyor", f = "düzeldi", p = {
3
3
  "(Default)": "(Normal)",
4
4
  Audio: "Ses",
5
+ "Autoplay next episode": "Sonraki bölümü otomatik oynat",
5
6
  Copied: t,
6
7
  Copy: n,
7
8
  "Copy the errors": "Hataları kopyala",
@@ -2,6 +2,7 @@
2
2
  var e = "Аудіо", t = "Скопійовано", n = "Копіювати", r = "Вимкнено", i = "Вимкнути звук", a = "Пауза", o = "Відтворити", s = "Якість", c = "Дивитися знову", l = "Налаштування", u = "Субтитри", d = "Недоступно", f = "відновлено", p = {
3
3
  "(Default)": "(Звичайна)",
4
4
  Audio: e,
5
+ "Autoplay next episode": "Автоматично вмикати наступну серію",
5
6
  Copied: t,
6
7
  Copy: n,
7
8
  "Copy the errors": "Копіювати помилки",
@@ -2,6 +2,7 @@
2
2
  var e = "Âm thanh", t = "Đã sao chép", n = "Sao chép", r = "Tắt", i = "Tắt tiếng", a = "Tạm dừng", o = "Phát", s = "Chất lượng", c = "Phát lại", l = "Cài đặt", u = "Phụ đề", d = "Không khả dụng", f = "đã khôi phục", p = {
3
3
  "(Default)": "(Mặc định)",
4
4
  Audio: e,
5
+ "Autoplay next episode": "Tự động phát tập tiếp theo",
5
6
  Copied: t,
6
7
  Copy: n,
7
8
  "Copy the errors": "Sao chép lỗi",
@@ -2,6 +2,7 @@
2
2
  var e = "音频", t = "已复制", n = "复制", r = "关闭", i = "静音", a = "暂停", o = "播放", s = "画质", c = "重新播放", l = "设置", u = "字幕", d = "不可用", f = "已恢复", p = {
3
3
  "(Default)": "(正常)",
4
4
  Audio: e,
5
+ "Autoplay next episode": "自动播放下一集",
5
6
  Copied: t,
6
7
  Copy: n,
7
8
  "Copy the errors": "复制错误信息",
@@ -2,6 +2,7 @@
2
2
  var e = "音訊", t = "已複製", n = "複製", r = "關閉", i = "靜音", a = "暫停", o = "播放", s = "畫質", c = "重新播放", l = "設定", u = "字幕", d = "無法使用", f = "已恢復", p = {
3
3
  "(Default)": "(正常)",
4
4
  Audio: e,
5
+ "Autoplay next episode": "自動播放下一集",
5
6
  Copied: t,
6
7
  Copy: n,
7
8
  "Copy the errors": "複製錯誤訊息",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@banou/media-player",
3
- "version": "0.10.40",
3
+ "version": "0.10.41",
4
4
  "description": "A video player for containers and codecs the browser cannot play natively, remuxed on the fly",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/lib/index.tsx CHANGED
@@ -27,7 +27,8 @@ export type { PlayerStore } from './react/player'
27
27
  // only hook the chrome needs.
28
28
  export { sourceFeature } from './react/source-feature'
29
29
  export type {
30
- DownloadedRange, PassThroughControl, PlaybackErrorEntry, SourceState, ViewportBox, VolumeNormalizerControl,
30
+ AutoplayNextControl, DownloadedRange, PassThroughControl, PlaybackErrorEntry, SourceState, ViewportBox,
31
+ VolumeNormalizerControl,
31
32
  } from './react/source-feature'
32
33
 
33
34
  export { useSeekThumbnails } from './react/hooks/use-thumbnails'
package/src/lib/labels.ts CHANGED
@@ -33,6 +33,7 @@ export const LABELS = {
33
33
  defaultSpeed: '(Default)',
34
34
  speed: '{rate}x',
35
35
  normalizeVolume: 'Normalize volume',
36
+ autoplayNext: 'Autoplay next episode',
36
37
  unavailable: 'Unavailable',
37
38
  switchFailed: 'Could not switch. Try again.',
38
39
  track: 'Track {number}',
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "(Default)": "(عادية)",
3
3
  "Audio": "الصوت",
4
+ "Autoplay next episode": "تشغيل الحلقة التالية تلقائيًا",
4
5
  "Copied": "تم النسخ",
5
6
  "Copy": "نسخ",
6
7
  "Copy the errors": "نسخ الأخطاء",
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "(Default)": "(Normální)",
3
3
  "Audio": "Zvuk",
4
+ "Autoplay next episode": "Automaticky přehrát další díl",
4
5
  "Copied": "Zkopírováno",
5
6
  "Copy": "Kopírovat",
6
7
  "Copy the errors": "Kopírovat chyby",
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "(Default)": "(Normal)",
3
3
  "Audio": "Audio",
4
+ "Autoplay next episode": "Nächste Folge automatisch abspielen",
4
5
  "Copied": "Kopiert",
5
6
  "Copy": "Kopieren",
6
7
  "Copy the errors": "Fehler kopieren",
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "(Default)": "(Κανονική)",
3
3
  "Audio": "Ήχος",
4
+ "Autoplay next episode": "Αυτόματη αναπαραγωγή επόμενου επεισοδίου",
4
5
  "Copied": "Αντιγράφηκε",
5
6
  "Copy": "Αντιγραφή",
6
7
  "Copy the errors": "Αντιγραφή σφαλμάτων",
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "(Default)": "(Normal)",
3
3
  "Audio": "Audio",
4
+ "Autoplay next episode": "Reproducción automática del siguiente episodio",
4
5
  "Copied": "Copiado",
5
6
  "Copy": "Copiar",
6
7
  "Copy the errors": "Copiar los errores",
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "(Default)": "(Normale)",
3
3
  "Audio": "Audio",
4
+ "Autoplay next episode": "Lecture automatique de l’épisode suivant",
4
5
  "Copied": "Copié",
5
6
  "Copy": "Copier",
6
7
  "Copy the errors": "Copier les erreurs",
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "(Default)": "(רגילה)",
3
3
  "Audio": "שמע",
4
+ "Autoplay next episode": "הפעלה אוטומטית של הפרק הבא",
4
5
  "Copied": "הועתק",
5
6
  "Copy": "העתקה",
6
7
  "Copy the errors": "העתקת השגיאות",
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "(Default)": "(सामान्य)",
3
3
  "Audio": "ऑडियो",
4
+ "Autoplay next episode": "अगला एपिसोड अपने आप चलाएं",
4
5
  "Copied": "कॉपी हो गया",
5
6
  "Copy": "कॉपी करें",
6
7
  "Copy the errors": "गड़बड़ियां कॉपी करें",
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "(Default)": "(Normál)",
3
3
  "Audio": "Hang",
4
+ "Autoplay next episode": "Következő rész automatikus lejátszása",
4
5
  "Copied": "Másolva",
5
6
  "Copy": "Másolás",
6
7
  "Copy the errors": "Hibák másolása",
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "(Default)": "(Normal)",
3
3
  "Audio": "Audio",
4
+ "Autoplay next episode": "Putar otomatis episode berikutnya",
4
5
  "Copied": "Disalin",
5
6
  "Copy": "Salin",
6
7
  "Copy the errors": "Salin kesalahan",
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "(Default)": "(Normale)",
3
3
  "Audio": "Audio",
4
+ "Autoplay next episode": "Riproduzione automatica dell’episodio successivo",
4
5
  "Copied": "Copiato",
5
6
  "Copy": "Copia",
6
7
  "Copy the errors": "Copia gli errori",