moqtail 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { d as MOQtailPlayerOptions, p as StreamType, u as MOQtailPlayer } from "../index-BtemTtwe.cjs";
16
+ import { v as MOQtailPlayer, x as StreamType, y as MOQtailPlayerOptions } from "../index-Bn8VlVoN.cjs";
17
17
  import { CustomVideoElement } from "custom-media-element";
18
18
  declare const MOQtailVideoElement_base: import("media-tracks").WithMediaTracks<CustomVideoElement>;
19
19
  /** @public A `<video>`-backed element implementing HTMLMediaElement and the media-ui-extensions IDL. */
@@ -33,10 +33,19 @@ export declare class MOQtailVideoElement extends MOQtailVideoElement_base {
33
33
  /** Proposal 0007: where the live edge starts, in seconds; `NaN` on demand. */
34
34
  get liveEdgeStart(): number;
35
35
  /**
36
- * Proposal 0007: `Infinity` while live, since earlier groups stay seekable through FETCH; `NaN`
37
- * otherwise. Players such as Video.js treat a media as live only when it has this and `liveEdgeStart`.
36
+ * Proposal 0007: live, `Infinity` with an accessible window (DVR) and `0` without; `NaN` otherwise.
37
+ * Players such as Video.js treat a media as live only when it has this and `liveEdgeStart`.
38
38
  */
39
39
  get targetLiveWindow(): number;
40
+ /**
41
+ * Live with an accessible window, the element's times count from the window's start: seekbars
42
+ * such as Video.js's start at 0. The inner video and the player keep media time.
43
+ */
44
+ get currentTime(): number;
45
+ set currentTime(value: number);
46
+ /** Live, the accessible window, or nothing without one. */
47
+ get seekable(): TimeRanges;
48
+ get buffered(): TimeRanges;
40
49
  get error(): MediaError | null;
41
50
  /** The inner video's `error` is left out: the sink recovers from those, and fatal ones arrive through the player. */
42
51
  handleEvent(event: Event): void;
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { d as MOQtailPlayerOptions, p as StreamType, u as MOQtailPlayer } from "../index-B-BMK-b6.mjs";
16
+ import { v as MOQtailPlayer, x as StreamType, y as MOQtailPlayerOptions } from "../index-Ch5QUygw.mjs";
17
17
  import { CustomVideoElement } from "custom-media-element";
18
18
  declare const MOQtailVideoElement_base: import("media-tracks").WithMediaTracks<CustomVideoElement>;
19
19
  /** @public A `<video>`-backed element implementing HTMLMediaElement and the media-ui-extensions IDL. */
@@ -33,10 +33,19 @@ export declare class MOQtailVideoElement extends MOQtailVideoElement_base {
33
33
  /** Proposal 0007: where the live edge starts, in seconds; `NaN` on demand. */
34
34
  get liveEdgeStart(): number;
35
35
  /**
36
- * Proposal 0007: `Infinity` while live, since earlier groups stay seekable through FETCH; `NaN`
37
- * otherwise. Players such as Video.js treat a media as live only when it has this and `liveEdgeStart`.
36
+ * Proposal 0007: live, `Infinity` with an accessible window (DVR) and `0` without; `NaN` otherwise.
37
+ * Players such as Video.js treat a media as live only when it has this and `liveEdgeStart`.
38
38
  */
39
39
  get targetLiveWindow(): number;
40
+ /**
41
+ * Live with an accessible window, the element's times count from the window's start: seekbars
42
+ * such as Video.js's start at 0. The inner video and the player keep media time.
43
+ */
44
+ get currentTime(): number;
45
+ set currentTime(value: number);
46
+ /** Live, the accessible window, or nothing without one. */
47
+ get seekable(): TimeRanges;
48
+ get buffered(): TimeRanges;
40
49
  get error(): MediaError | null;
41
50
  /** The inner video's `error` is left out: the sink recovers from those, and fatal ones arrive through the player. */
42
51
  handleEvent(event: Event): void;
@@ -1,6 +1,5 @@
1
+ import { i as abr, k as PlayerError, s as liveBuffer, u as MOQtailPlayer } from "../player-DfJB6vBH.mjs";
1
2
  import { i as logger } from "../emitter-UbeRcbuf.mjs";
2
- import { T as PlayerError, i as abr, o as liveBuffer, s as MOQtailPlayer } from "../player-DcctWhyM.mjs";
3
- import "../util.mjs";
4
3
  import { CustomVideoElement } from "custom-media-element";
5
4
  import { MediaTracksMixin } from "media-tracks";
6
5
  // src/player/component/renditions.ts
@@ -195,14 +194,43 @@ var MOQtailVideoElement = class extends MediaTracksMixin(CustomVideoElement) {
195
194
  }
196
195
  /** Proposal 0007: where the live edge starts, in seconds; `NaN` on demand. */
197
196
  get liveEdgeStart() {
198
- return this.#player?.mediaSink?.liveEdgeStart ?? NaN;
197
+ return (this.#player?.mediaSink?.liveEdgeStart ?? NaN) - this.#offset();
199
198
  }
200
199
  /**
201
- * Proposal 0007: `Infinity` while live, since earlier groups stay seekable through FETCH; `NaN`
202
- * otherwise. Players such as Video.js treat a media as live only when it has this and `liveEdgeStart`.
200
+ * Proposal 0007: live, `Infinity` with an accessible window (DVR) and `0` without; `NaN` otherwise.
201
+ * Players such as Video.js treat a media as live only when it has this and `liveEdgeStart`.
203
202
  */
204
203
  get targetLiveWindow() {
205
- return this.#streamType === "live" ? Infinity : NaN;
204
+ if (this.#streamType !== "live") return NaN;
205
+ return this.#dvrRange ? Infinity : 0;
206
+ }
207
+ /**
208
+ * Live with an accessible window, the element's times count from the window's start: seekbars
209
+ * such as Video.js's start at 0. The inner video and the player keep media time.
210
+ */
211
+ get currentTime() {
212
+ return this.nativeEl.currentTime - this.#offset();
213
+ }
214
+ set currentTime(value) {
215
+ if (this.#streamType === "live" && !this.#dvrRange) return;
216
+ this.nativeEl.currentTime = value + this.#offset();
217
+ }
218
+ /** Live, the accessible window, or nothing without one. */
219
+ get seekable() {
220
+ if (this.#streamType !== "live") return this.nativeEl.seekable;
221
+ const range = this.#dvrRange;
222
+ return timeRanges(range ? [[0, range.end - range.start]] : []);
223
+ }
224
+ get buffered() {
225
+ const offset = this.#offset();
226
+ const native = this.nativeEl.buffered;
227
+ if (offset === 0) return native;
228
+ const pairs = [];
229
+ for (let i = 0; i < native.length; i++) {
230
+ const end = native.end(i) - offset;
231
+ if (end > 0) pairs.push([Math.max(0, native.start(i) - offset), end]);
232
+ }
233
+ return timeRanges(pairs);
206
234
  }
207
235
  get error() {
208
236
  return this.#error;
@@ -263,6 +291,12 @@ var MOQtailVideoElement = class extends MediaTracksMixin(CustomVideoElement) {
263
291
  this.#setStreamType("unknown");
264
292
  if (player) this.#destroyed = player.destroy().catch(() => {});
265
293
  }
294
+ get #dvrRange() {
295
+ return this.#streamType === "live" ? this.#player?.mediaSink?.dvrRange : void 0;
296
+ }
297
+ #offset() {
298
+ return this.#dvrRange?.start ?? 0;
299
+ }
266
300
  #setStreamType(type) {
267
301
  if (type === this.#streamType) return;
268
302
  this.#streamType = type;
@@ -280,6 +314,19 @@ function asPlayerError(error) {
280
314
  cause: error
281
315
  });
282
316
  }
317
+ /** `TimeRanges` can't be constructed either. */
318
+ function timeRanges(pairs) {
319
+ const at = (i, edge) => {
320
+ const pair = pairs[i];
321
+ if (!pair) throw new DOMException(`No range ${i}`, "IndexSizeError");
322
+ return pair[edge];
323
+ };
324
+ return {
325
+ length: pairs.length,
326
+ start: (i) => at(i, 0),
327
+ end: (i) => at(i, 1)
328
+ };
329
+ }
283
330
  /** `MediaError` can't be constructed, so this has its shape. */
284
331
  function mediaError(error) {
285
332
  return {