bigscreen-player 9.0.0 → 9.0.2

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.
@@ -1,5 +1,5 @@
1
1
  import { fromXML, generateISD, renderHTML } from 'smp-imsc';
2
- import { f as findSegmentTemplate, L as LoadUrl, a as DebugTool, P as Plugins, U as Utils, D as DOMHelpers } from './main-5b4d5af8.js';
2
+ import { f as findSegmentTemplate, L as LoadUrl, a as DebugTool, P as Plugins, U as Utils, D as DOMHelpers } from './main-166a437e.js';
3
3
  import 'tslib';
4
4
 
5
5
  const SEGMENTS_BUFFER_SIZE = 3;
@@ -312,7 +312,8 @@ function IMSCSubtitles(mediaPlayer, autoStart, parentElement, mediaSources, defa
312
312
  }
313
313
 
314
314
  function isValidTime(time) {
315
- return time >= 0
315
+ // A newly loaded video element reports currentTime as 0
316
+ return time > 0
316
317
  }
317
318
 
318
319
  function getCurrentTime() {
@@ -1,4 +1,4 @@
1
- import { D as DOMHelpers, a as DebugTool, P as Plugins, L as LoadUrl, T as TransportControlPosition } from './main-5b4d5af8.js';
1
+ import { D as DOMHelpers, a as DebugTool, P as Plugins, L as LoadUrl, T as TransportControlPosition } from './main-166a437e.js';
2
2
  import 'tslib';
3
3
 
4
4
  /**
@@ -5668,7 +5668,7 @@ BasicStrategy.getLiveSupport = () => LiveSupport.SEEKABLE;
5668
5668
  function StrategyPicker() {
5669
5669
  return new Promise((resolve, reject) => {
5670
5670
  if (window.bigscreenPlayer.playbackStrategy === PlaybackStrategy.MSE) {
5671
- return import('./msestrategy-31c89861.js')
5671
+ return import('./msestrategy-7d9b39fa.js')
5672
5672
  .then(({ default: MSEStrategy }) => resolve(MSEStrategy))
5673
5673
  .catch((reason) => {
5674
5674
  const error = new Error(isError(reason) ? reason.message : undefined);
@@ -6356,21 +6356,7 @@ const PauseTriggers = {
6356
6356
  DEVICE: 3,
6357
6357
  };
6358
6358
 
6359
- /**
6360
- * Enums for WindowTypes
6361
- * @readonly
6362
- * @enum {string}
6363
- */
6364
- const WindowTypes = {
6365
- /** Media with a duration */
6366
- STATIC: "staticWindow",
6367
- /** Media with a start time but without a duration until an indeterminate time in the future */
6368
- GROWING: "growingWindow",
6369
- /** Media with a rewind window that progresses through a media timeline */
6370
- SLIDING: "slidingWindow",
6371
- };
6372
-
6373
- var Version = "9.0.0";
6359
+ var Version = "9.0.2";
6374
6360
 
6375
6361
  /* eslint-disable no-use-before-define */
6376
6362
 
@@ -6387,11 +6373,12 @@ let currentTime;
6387
6373
  let isSeeking;
6388
6374
  let seekableRange;
6389
6375
  let duration;
6390
- let liveWindowStart;
6376
+ let initialPlaybackTime = null;
6377
+ let liveWindowStart = 0;
6391
6378
  let pausedState = true;
6392
6379
  let endedState;
6393
6380
  let mediaKind;
6394
- let windowType;
6381
+ let manifestType;
6395
6382
  let subtitlesAvailable;
6396
6383
  let subtitlesEnabled;
6397
6384
  let subtitlesHidden;
@@ -6414,7 +6401,6 @@ let autoProgress;
6414
6401
  let autoProgressInterval;
6415
6402
  let initialBuffering = false;
6416
6403
 
6417
- let liveWindowData;
6418
6404
  let manifestError;
6419
6405
 
6420
6406
  let excludedFuncs = [
@@ -6425,23 +6411,31 @@ let excludedFuncs = [
6425
6411
  "toggleDebug",
6426
6412
  "getLogLevels",
6427
6413
  "setLogLevel",
6428
- "convertEpochMsToVideoTimeSeconds",
6429
- "clearSubtitleExample",
6430
- "areSubtitlesCustomisable",
6431
6414
  "setPlaybackRate",
6432
6415
  "getPlaybackRate",
6416
+ "clearSubtitleExample",
6417
+ "areSubtitlesCustomisable",
6418
+ "convertAvailabilityTimeToPresentationTimeInSeconds",
6419
+ "convertMediaSampleTimeToPresentationTimeInSeconds",
6420
+ "convertPresentationTimeToAvailabilityTimeInMilliseconds",
6421
+ "convertPresentationTimeToMediaSampleTimeInSeconds",
6433
6422
  ];
6434
6423
 
6424
+ let compatibilityFuncs = ["getWindowType", "convertVideoTimeSecondsToEpochMs", "convertEpochMsToVideoTimeSeconds"];
6425
+
6435
6426
  function startProgress(progressCause) {
6436
6427
  setTimeout(() => {
6437
6428
  if (!autoProgressInterval) {
6438
6429
  mockingHooks.changeState(MediaState.PLAYING, progressCause);
6430
+
6439
6431
  autoProgressInterval = setInterval(() => {
6440
- if (windowType !== WindowTypes.STATIC && seekableRange.start && seekableRange.end) {
6432
+ if (manifestType !== ManifestType.STATIC && seekableRange.start && seekableRange.end) {
6441
6433
  seekableRange.start += 0.5;
6442
6434
  seekableRange.end += 0.5;
6443
6435
  }
6436
+
6444
6437
  mockingHooks.progressTime(currentTime + 0.5);
6438
+
6445
6439
  if (currentTime >= duration) {
6446
6440
  clearInterval(autoProgressInterval);
6447
6441
  mockingHooks.changeState(MediaState.ENDED);
@@ -6459,12 +6453,16 @@ function stopProgress() {
6459
6453
  }
6460
6454
 
6461
6455
  function mock(BigscreenPlayer, opts) {
6462
- autoProgress = opts && opts.autoProgress;
6456
+ autoProgress = opts?.autoProgress;
6463
6457
 
6464
- if (opts && opts.excludedFuncs) {
6458
+ if (opts?.excludedFuncs) {
6465
6459
  excludedFuncs = [...excludedFuncs, ...opts.excludedFuncs];
6466
6460
  }
6467
6461
 
6462
+ if (opts?.compatibilityFuncs) {
6463
+ compatibilityFuncs = [...compatibilityFuncs, ...opts.compatibilityFuncs];
6464
+ }
6465
+
6468
6466
  if (mockStatus.currentlyMocked) {
6469
6467
  throw new Error("mock() was called while BigscreenPlayer was already mocked")
6470
6468
  }
@@ -6482,6 +6480,14 @@ function mock(BigscreenPlayer, opts) {
6482
6480
  for (const hook in mockingHooks) {
6483
6481
  BigscreenPlayer[hook] = mockingHooks[hook];
6484
6482
  }
6483
+
6484
+ // Add compatibility functions
6485
+ for (let funcsSoFar = 0; funcsSoFar < compatibilityFuncs.length; funcsSoFar += 1) {
6486
+ const funcName = compatibilityFuncs[funcsSoFar];
6487
+
6488
+ BigscreenPlayer[funcName] = mockFunctions[funcName];
6489
+ }
6490
+
6485
6491
  mockStatus = { currentlyMocked: true, mode: mockModes.PLAIN };
6486
6492
  }
6487
6493
 
@@ -6537,24 +6543,25 @@ function callSubtitlesCallbacks(enabled) {
6537
6543
  }
6538
6544
 
6539
6545
  const mockFunctions = {
6540
- init(playbackElement, bigscreenPlayerData, newWindowType, enableSubtitles, callbacks) {
6541
- currentTime = (bigscreenPlayerData && bigscreenPlayerData.initialPlaybackTime) || 0;
6542
- liveWindowStart = undefined;
6546
+ init(playbackElement, bigscreenPlayerData, callbacks) {
6547
+ initialPlaybackTime =
6548
+ typeof bigscreenPlayerData?.initialPlaybackTime === "number" ? bigscreenPlayerData.initialPlaybackTime : null;
6549
+ currentTime = initialPlaybackTime == null ? 0 : initialPlaybackTime;
6550
+ liveWindowStart = 0;
6543
6551
  pausedState = true;
6544
6552
  endedState = false;
6545
- mediaKind = (bigscreenPlayerData && bigscreenPlayerData.media && bigscreenPlayerData.media.kind) || "video";
6546
- windowType = newWindowType || WindowTypes.STATIC;
6553
+ mediaKind = bigscreenPlayerData?.media?.kind || "video";
6547
6554
  subtitlesAvailable = true;
6548
- subtitlesEnabled = enableSubtitles;
6555
+ subtitlesEnabled = bigscreenPlayerData?.enableSubtitles ?? false;
6549
6556
  broadcastMixADAvailable = false;
6550
6557
  broadcastMixADEnabled = false;
6551
6558
  canSeekState = true;
6552
6559
  canPauseState = true;
6553
- sourceList = bigscreenPlayerData && bigscreenPlayerData.media && bigscreenPlayerData.media.urls;
6554
- source = sourceList && sourceList[0].url;
6555
- cdn = sourceList && sourceList[0].cdn;
6560
+ sourceList = bigscreenPlayerData?.media?.urls;
6561
+ source = sourceList?.[0].url;
6562
+ cdn = sourceList?.[0].cdn;
6556
6563
 
6557
- duration = windowType === WindowTypes.STATIC ? 4808 : Infinity;
6564
+ duration = manifestType === ManifestType.STATIC ? 4808 : Infinity;
6558
6565
  seekableRange = { start: 0, end: 4808 };
6559
6566
 
6560
6567
  if (manifestError) {
@@ -6572,11 +6579,11 @@ const mockFunctions = {
6572
6579
 
6573
6580
  initialised = true;
6574
6581
 
6575
- if (enableSubtitles) {
6582
+ if (subtitlesEnabled) {
6576
6583
  callSubtitlesCallbacks(true);
6577
6584
  }
6578
6585
 
6579
- if (callbacks && callbacks.onSuccess) {
6586
+ if (callbacks?.onSuccess) {
6580
6587
  callbacks.onSuccess();
6581
6588
  }
6582
6589
  },
@@ -6609,8 +6616,9 @@ const mockFunctions = {
6609
6616
  stateChangeCallbacks = stateChangeCallbacks.filter((existingCallback) => callback !== existingCallback);
6610
6617
  },
6611
6618
  setCurrentTime(time) {
6612
- currentTime = time;
6619
+ currentTime = time - liveWindowStart;
6613
6620
  isSeeking = true;
6621
+
6614
6622
  if (autoProgress) {
6615
6623
  mockingHooks.changeState(MediaState.WAITING, "other");
6616
6624
  if (!pausedState) {
@@ -6621,16 +6629,21 @@ const mockFunctions = {
6621
6629
  }
6622
6630
  },
6623
6631
  getCurrentTime() {
6624
- return currentTime
6632
+ return currentTime + liveWindowStart
6633
+ },
6634
+ getInitialPlaybackTime() {
6635
+ return initialPlaybackTime
6625
6636
  },
6626
6637
  getMediaKind() {
6627
6638
  return mediaKind
6628
6639
  },
6629
6640
  getWindowType() {
6630
- return windowType
6641
+ return manifestType === ManifestType.STATIC ? "staticWindow" : "slidingWindow"
6631
6642
  },
6632
6643
  getSeekableRange() {
6633
- return seekableRange
6644
+ return seekableRange?.start && seekableRange?.end
6645
+ ? { start: seekableRange.start + liveWindowStart, end: seekableRange.end + liveWindowStart }
6646
+ : seekableRange
6634
6647
  },
6635
6648
  getDuration() {
6636
6649
  return duration
@@ -6679,9 +6692,6 @@ const mockFunctions = {
6679
6692
  canPause() {
6680
6693
  return canPauseState
6681
6694
  },
6682
- convertVideoTimeSecondsToEpochMs(seconds) {
6683
- return liveWindowStart ? liveWindowStart + seconds * 1000 : undefined
6684
- },
6685
6695
  transitions() {
6686
6696
  return {
6687
6697
  canBePaused() {
@@ -6739,16 +6749,17 @@ const mockFunctions = {
6739
6749
  unregisterPlugin(plugin) {
6740
6750
  Plugins.unregisterPlugin(plugin);
6741
6751
  },
6742
- getLiveWindowData() {
6743
- if (windowType === WindowTypes.STATIC) {
6744
- return {}
6745
- }
6746
- return {
6747
- windowStartTime: liveWindowData.windowStartTime,
6748
- windowEndTime: liveWindowData.windowEndTime,
6749
- initialPlaybackTime: liveWindowData.initialPlaybackTime,
6750
- serverDate: liveWindowData.serverDate,
6751
- }
6752
+ getPresentationTimeOffsetInMilliseconds() {
6753
+ return 0
6754
+ },
6755
+ getTimeShiftBufferDepthInMilliseconds() {
6756
+ return manifestType === ManifestType.STATIC ? 0 : 7200000
6757
+ },
6758
+ convertVideoTimeSecondsToEpochMs(seconds) {
6759
+ return seconds
6760
+ },
6761
+ convertEpochMsToVideoTimeSeconds(milliseconds) {
6762
+ return milliseconds
6752
6763
  },
6753
6764
  };
6754
6765
 
@@ -6813,9 +6824,9 @@ const mockingHooks = {
6813
6824
  }
6814
6825
  },
6815
6826
  progressTime(time) {
6816
- currentTime = time;
6827
+ currentTime = time + liveWindowStart;
6817
6828
  CallCallbacks(timeUpdateCallbacks, {
6818
- currentTime: time,
6829
+ currentTime: time + liveWindowStart,
6819
6830
  endOfStream,
6820
6831
  });
6821
6832
  },
@@ -6832,7 +6843,7 @@ const mockingHooks = {
6832
6843
  mediaKind = kind;
6833
6844
  },
6834
6845
  setWindowType(type) {
6835
- windowType = type;
6846
+ manifestType = type === "staticWindow" ? "static" : "dynamic";
6836
6847
  },
6837
6848
  setCanSeek(value) {
6838
6849
  canSeekState = value;
@@ -6897,9 +6908,6 @@ const mockingHooks = {
6897
6908
  setInitialBuffering(value) {
6898
6909
  initialBuffering = value;
6899
6910
  },
6900
- setLiveWindowData(newLiveWindowData) {
6901
- liveWindowData = newLiveWindowData;
6902
- },
6903
6911
  };
6904
6912
 
6905
6913
  var MockBigscreenPlayer = {
@@ -7505,7 +7513,7 @@ function Subtitles(mediaPlayer, autoStart, playbackElement, defaultStyleOpts, me
7505
7513
 
7506
7514
  if (available()) {
7507
7515
  if (useLegacySubs) {
7508
- import('./legacysubtitles-e745299b.js')
7516
+ import('./legacysubtitles-70a5436b.js')
7509
7517
  .then(({ default: LegacySubtitles }) => {
7510
7518
  subtitlesContainer = LegacySubtitles(mediaPlayer, autoStart, playbackElement, mediaSources, defaultStyleOpts);
7511
7519
  callback(subtitlesEnabled);
@@ -7514,7 +7522,7 @@ function Subtitles(mediaPlayer, autoStart, playbackElement, defaultStyleOpts, me
7514
7522
  Plugins.interface.onSubtitlesDynamicLoadError();
7515
7523
  });
7516
7524
  } else {
7517
- import('./imscsubtitles-72c8e371.js')
7525
+ import('./imscsubtitles-0d663dc5.js')
7518
7526
  .then(({ default: IMSCSubtitles }) => {
7519
7527
  subtitlesContainer = IMSCSubtitles(mediaPlayer, autoStart, playbackElement, mediaSources, defaultStyleOpts);
7520
7528
  callback(subtitlesEnabled);
@@ -8385,4 +8393,18 @@ const TransportControlPosition = {
8385
8393
  FULLSCREEN: 16,
8386
8394
  };
8387
8395
 
8396
+ /**
8397
+ * Enums for WindowTypes
8398
+ * @readonly
8399
+ * @enum {string}
8400
+ */
8401
+ const WindowTypes = {
8402
+ /** Media with a duration */
8403
+ STATIC: "staticWindow",
8404
+ /** Media with a start time but without a duration until an indeterminate time in the future */
8405
+ GROWING: "growingWindow",
8406
+ /** Media with a rewind window that progresses through a media timeline */
8407
+ SLIDING: "slidingWindow",
8408
+ };
8409
+
8388
8410
  export { BigscreenPlayer as B, DOMHelpers as D, EntryCategory as E, LoadUrl as L, MediaKinds as M, Plugins as P, TransportControlPosition as T, Utils as U, WindowTypes as W, DebugTool as a, LiveSupport as b, ManifestType as c, MediaState as d, autoResumeAtStartOfRange as e, findSegmentTemplate as f, MockBigscreenPlayer as g, PauseTriggers as h, PlaybackStrategy as i, TransferFormat as j, Timeline as k, isMessage as l, isMetric as m, isTrace as n };
package/dist/esm/main.js CHANGED
@@ -1,2 +1,2 @@
1
- export { B as BigscreenPlayer, a as DebugTool, E as EntryCategory, b as LiveSupport, c as ManifestType, M as MediaKinds, d as MediaState, g as MockBigscreenPlayer, h as PauseTriggers, i as PlaybackStrategy, k as Timeline, j as TransferFormat, T as TransportControlPosition, W as WindowTypes, l as isMessage, m as isMetric, n as isTrace } from './main-5b4d5af8.js';
1
+ export { B as BigscreenPlayer, a as DebugTool, E as EntryCategory, b as LiveSupport, c as ManifestType, M as MediaKinds, d as MediaState, g as MockBigscreenPlayer, h as PauseTriggers, i as PlaybackStrategy, k as Timeline, j as TransferFormat, T as TransportControlPosition, W as WindowTypes, l as isMessage, m as isMetric, n as isTrace } from './main-166a437e.js';
2
2
  import 'tslib';
@@ -1,5 +1,5 @@
1
1
  import { MediaPlayer } from 'dashjs/index_mediaplayerOnly';
2
- import { U as Utils, b as LiveSupport, M as MediaKinds, a as DebugTool, c as ManifestType, d as MediaState, P as Plugins, e as autoResumeAtStartOfRange, D as DOMHelpers } from './main-5b4d5af8.js';
2
+ import { U as Utils, b as LiveSupport, M as MediaKinds, a as DebugTool, c as ManifestType, d as MediaState, P as Plugins, e as autoResumeAtStartOfRange, D as DOMHelpers } from './main-166a437e.js';
3
3
  import 'tslib';
4
4
 
5
5
  function filter(manifest, representationOptions) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bigscreen-player",
3
- "version": "9.0.0",
3
+ "version": "9.0.2",
4
4
  "type": "module",
5
5
  "description": "Simplified media playback for bigscreen devices.",
6
6
  "main": "dist/esm/main.js",