bigscreen-player 7.1.4 → 8.0.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.
@@ -1,5 +1,5 @@
1
1
  import { fromXML, generateISD, renderHTML } from 'smp-imsc';
2
- import { f as findSegmentTemplate, L as LoadUrl, a as DebugToolInstance, P as Plugins, U as Utils, D as DOMHelpers } from './main-80542965.js';
2
+ import { f as findSegmentTemplate, L as LoadUrl, a as DebugToolInstance, P as Plugins, U as Utils, D as DOMHelpers } from './main-6f0a0874.js';
3
3
 
4
4
  const SEGMENTS_BUFFER_SIZE = 3;
5
5
  const LOAD_ERROR_COUNT_MAX = 3;
@@ -1,4 +1,4 @@
1
- import { D as DOMHelpers, a as DebugToolInstance, P as Plugins, L as LoadUrl, T as TransportControlPosition } from './main-80542965.js';
1
+ import { D as DOMHelpers, a as DebugToolInstance, P as Plugins, L as LoadUrl, T as TransportControlPosition } from './main-6f0a0874.js';
2
2
 
3
3
  /**
4
4
  * Safely checks if an attribute exists on an element.
@@ -224,9 +224,9 @@ let plugins = [];
224
224
  function callOnAllPlugins(funcKey, evt) {
225
225
  const clonedEvent = Utils.deepClone(evt);
226
226
 
227
- for (const i in plugins) {
228
- if (plugins[i][funcKey]) {
229
- plugins[i][funcKey](clonedEvent);
227
+ for (const plugin in plugins) {
228
+ if (plugins[plugin][funcKey]) {
229
+ plugins[plugin][funcKey](clonedEvent);
230
230
  }
231
231
  }
232
232
  }
@@ -240,9 +240,9 @@ var Plugins = {
240
240
  if (!plugin && plugins.length > 0) {
241
241
  plugins = [];
242
242
  } else {
243
- for (let i = plugins.length - 1; i >= 0; i--) {
244
- if (plugins[i] === plugin) {
245
- plugins.splice(i, 1);
243
+ for (let pluginsIndex = plugins.length - 1; pluginsIndex >= 0; pluginsIndex--) {
244
+ if (plugins[pluginsIndex] === plugin) {
245
+ plugins.splice(pluginsIndex, 1);
246
246
  }
247
247
  }
248
248
  }
@@ -266,6 +266,7 @@ var Plugins = {
266
266
  onSubtitlesTransformError: (evt) => callOnAllPlugins("onSubtitlesTransformError", evt),
267
267
  onSubtitlesRenderError: (evt) => callOnAllPlugins("onSubtitlesRenderError", evt),
268
268
  onSubtitlesDynamicLoadError: (evt) => callOnAllPlugins("onSubtitlesDynamicLoadError", evt),
269
+ onFragmentContentLengthMismatch: (evt) => callOnAllPlugins("onFragmentContentLengthMismatch", evt),
269
270
  },
270
271
  };
271
272
 
@@ -5795,7 +5796,7 @@ BasicStrategy.getLiveSupport = () => LiveSupport.SEEKABLE;
5795
5796
  function StrategyPicker() {
5796
5797
  return new Promise((resolve, reject) => {
5797
5798
  if (window.bigscreenPlayer.playbackStrategy === PlaybackStrategy.MSE) {
5798
- return import('./msestrategy-88b92534.js')
5799
+ return import('./msestrategy-7c7ed9a4.js')
5799
5800
  .then(({ default: MSEStrategy }) => resolve(MSEStrategy))
5800
5801
  .catch(() => {
5801
5802
  reject({ error: "strategyDynamicLoadError" });
@@ -6244,7 +6245,7 @@ function CallCallbacks(callbacks, data) {
6244
6245
  }
6245
6246
  }
6246
6247
 
6247
- var version = "7.1.4";
6248
+ var version = "8.0.0";
6248
6249
 
6249
6250
  var sourceList;
6250
6251
  var source;
@@ -7636,7 +7637,7 @@ function Subtitles(mediaPlayer, autoStart, playbackElement, defaultStyleOpts, me
7636
7637
 
7637
7638
  if (available()) {
7638
7639
  if (useLegacySubs) {
7639
- import('./legacysubtitles-d16b77e9.js')
7640
+ import('./legacysubtitles-73514204.js')
7640
7641
  .then(({ default: LegacySubtitles }) => {
7641
7642
  subtitlesContainer = LegacySubtitles(mediaPlayer, autoStart, playbackElement, mediaSources, defaultStyleOpts);
7642
7643
  callback(subtitlesEnabled);
@@ -7645,7 +7646,7 @@ function Subtitles(mediaPlayer, autoStart, playbackElement, defaultStyleOpts, me
7645
7646
  Plugins.interface.onSubtitlesDynamicLoadError();
7646
7647
  });
7647
7648
  } else {
7648
- import('./imscsubtitles-6c92d7cf.js')
7649
+ import('./imscsubtitles-eeb3e4f7.js')
7649
7650
  .then(({ default: IMSCSubtitles }) => {
7650
7651
  subtitlesContainer = IMSCSubtitles(mediaPlayer, autoStart, playbackElement, mediaSources, defaultStyleOpts);
7651
7652
  callback(subtitlesEnabled);
package/dist/esm/main.js CHANGED
@@ -1 +1 @@
1
- export { B as BigscreenPlayer, b as LiveSupport, c as MediaKinds, M as MediaState, g as MockBigscreenPlayer, h as PauseTriggers, i as PlaybackStrategy, j as TransferFormat, T as TransportControlPosition, W as WindowTypes } from './main-80542965.js';
1
+ export { B as BigscreenPlayer, b as LiveSupport, c as MediaKinds, M as MediaState, g as MockBigscreenPlayer, h as PauseTriggers, i as PlaybackStrategy, j as TransferFormat, T as TransportControlPosition, W as WindowTypes } from './main-6f0a0874.js';
@@ -1,5 +1,5 @@
1
- import { W as WindowTypes, U as Utils, D as DOMHelpers, b as LiveSupport, M as MediaState, a as DebugToolInstance, P as Plugins, c as MediaKinds, d as TimeUtils, e as DynamicWindowUtils } from './main-80542965.js';
2
1
  import { MediaPlayer } from 'dashjs/index_mediaplayerOnly';
2
+ import { W as WindowTypes, U as Utils, D as DOMHelpers, b as LiveSupport, M as MediaState, a as DebugToolInstance, P as Plugins, c as MediaKinds, d as TimeUtils, e as DynamicWindowUtils } from './main-6f0a0874.js';
3
3
 
4
4
  function filter(manifest, representationOptions) {
5
5
  const constantFps = representationOptions.constantFps;
@@ -162,15 +162,44 @@ function buildSourceAnchor(
162
162
  return wholeSeconds === 0 ? "" : `#t=${wholeSeconds}`
163
163
  }
164
164
 
165
+ const DEFAULT_SETTINGS = {
166
+ liveDelay: 0,
167
+ seekDurationPadding: 1.1,
168
+ };
169
+
165
170
  function MSEStrategy(mediaSources, windowType, mediaKind, playbackElement, isUHD, customPlayerSettings) {
166
171
  let mediaPlayer;
167
172
  let mediaElement;
168
173
 
174
+ const playerSettings = Utils.merge(
175
+ {
176
+ debug: {
177
+ logLevel: 2,
178
+ },
179
+ streaming: {
180
+ blacklistExpiryTime: mediaSources.failoverResetTime(),
181
+ buffer: {
182
+ bufferToKeep: 4,
183
+ bufferTimeAtTopQuality: 12,
184
+ bufferTimeAtTopQualityLongForm: 15,
185
+ },
186
+ },
187
+ },
188
+ customPlayerSettings
189
+ );
190
+
169
191
  let eventCallbacks = [];
170
192
  let errorCallback;
171
193
  let timeUpdateCallback;
172
194
 
173
195
  let timeCorrection = mediaSources.time()?.timeCorrectionSeconds || 0;
196
+
197
+ const seekDurationPadding = isNaN(playerSettings.streaming?.seekDurationPadding)
198
+ ? DEFAULT_SETTINGS.seekDurationPadding
199
+ : playerSettings.streaming?.seekDurationPadding;
200
+ const liveDelay = isNaN(playerSettings.streaming?.delay?.liveDelay)
201
+ ? DEFAULT_SETTINGS.liveDelay
202
+ : playerSettings.streaming?.delay?.liveDelay;
174
203
  let failoverTime;
175
204
  let failoverZeroPoint;
176
205
  let refreshFailoverTime;
@@ -192,21 +221,6 @@ function MSEStrategy(mediaSources, windowType, mediaKind, playbackElement, isUHD
192
221
  },
193
222
  };
194
223
 
195
- const playerSettings = Utils.merge(
196
- {
197
- debug: {
198
- logLevel: 2,
199
- },
200
- streaming: {
201
- liveDelay: 1.1,
202
- bufferToKeep: 4,
203
- bufferTimeAtTopQuality: 12,
204
- bufferTimeAtTopQualityLongForm: 15,
205
- },
206
- },
207
- customPlayerSettings
208
- );
209
-
210
224
  const DashJSEvents = {
211
225
  LOG: "log",
212
226
  ERROR: "error",
@@ -223,6 +237,7 @@ function MSEStrategy(mediaSources, windowType, mediaKind, playbackElement, isUHD
223
237
  METRIC_ADDED: "metricAdded",
224
238
  METRIC_CHANGED: "metricChanged",
225
239
  STREAM_INITIALIZED: "streamInitialized",
240
+ FRAGMENT_CONTENT_LENGTH_MISMATCH: "fragmentContentLengthMismatch",
226
241
  };
227
242
 
228
243
  function onPlaying() {
@@ -353,10 +368,9 @@ function MSEStrategy(mediaSources, windowType, mediaKind, playbackElement, isUHD
353
368
  const setMseDuration = window.bigscreenPlayer.overrides && window.bigscreenPlayer.overrides.mseDurationOverride;
354
369
  if (setMseDuration && (windowType === WindowTypes.SLIDING || windowType === WindowTypes.GROWING)) {
355
370
  // Workaround for no setLiveSeekableRange/clearLiveSeekableRange
356
- mediaPlayer.setDuration(Number.MAX_SAFE_INTEGER);
371
+ mediaPlayer.setMediaDuration(Number.MAX_SAFE_INTEGER);
357
372
  }
358
373
 
359
- mediaPlayer.setBlacklistExpiryTime(mediaSources.failoverResetTime());
360
374
  emitPlayerInfo();
361
375
  }
362
376
 
@@ -468,6 +482,13 @@ function MSEStrategy(mediaSources, windowType, mediaKind, playbackElement, isUHD
468
482
  DebugToolInstance.verbose(event.message);
469
483
  }
470
484
 
485
+ function onFragmentContentLengthMismatch(event) {
486
+ DebugToolInstance.info(`Fragment Content Length Mismatch: ${event.responseUrl} (${event.mediaType})`);
487
+ DebugToolInstance.info(`Header Length ${event.headerLength}`);
488
+ DebugToolInstance.info(`Body Length ${event.bodyLength})`);
489
+ Plugins.interface.onFragmentContentLengthMismatch(event);
490
+ }
491
+
471
492
  function publishMediaState(mediaState) {
472
493
  for (let index = 0; index < eventCallbacks.length; index++) {
473
494
  eventCallbacks[index](mediaState);
@@ -491,17 +512,17 @@ function MSEStrategy(mediaSources, windowType, mediaKind, playbackElement, isUHD
491
512
  }
492
513
 
493
514
  function getClampedTime(time, range) {
494
- return Math.min(Math.max(time, range.start), range.end - playerSettings.streaming.liveDelay)
515
+ return Math.min(Math.max(time, range.start), range.end - Math.max(liveDelay, seekDurationPadding))
495
516
  }
496
517
 
497
518
  function load(mimeType, playbackTime) {
498
- if (!mediaPlayer) {
519
+ if (mediaPlayer) {
520
+ modifySource(refreshFailoverTime || failoverTime, failoverZeroPoint);
521
+ } else {
499
522
  failoverTime = playbackTime;
500
523
  setUpMediaElement(playbackElement);
501
524
  setUpMediaPlayer(playbackTime);
502
525
  setUpMediaListeners();
503
- } else {
504
- modifySource(refreshFailoverTime || failoverTime, failoverZeroPoint);
505
526
  }
506
527
  }
507
528
 
@@ -550,6 +571,7 @@ function MSEStrategy(mediaSources, windowType, mediaKind, playbackElement, isUHD
550
571
  mediaPlayer.on(DashJSEvents.LOG, onDebugLog);
551
572
  mediaPlayer.on(DashJSEvents.SERVICE_LOCATION_AVAILABLE, onServiceLocationAvailable);
552
573
  mediaPlayer.on(DashJSEvents.URL_RESOLUTION_FAILED, onURLResolutionFailed);
574
+ mediaPlayer.on(DashJSEvents.FRAGMENT_CONTENT_LENGTH_MISMATCH, onFragmentContentLengthMismatch);
553
575
  }
554
576
 
555
577
  function getSeekableRange() {
@@ -558,7 +580,7 @@ function MSEStrategy(mediaSources, windowType, mediaKind, playbackElement, isUHD
558
580
  if (dvrInfo) {
559
581
  return {
560
582
  start: dvrInfo.range.start - timeCorrection,
561
- end: dvrInfo.range.end - timeCorrection - playerSettings.streaming.liveDelay,
583
+ end: dvrInfo.range.end - timeCorrection - liveDelay,
562
584
  }
563
585
  }
564
586
  }
@@ -582,20 +604,20 @@ function MSEStrategy(mediaSources, windowType, mediaKind, playbackElement, isUHD
582
604
 
583
605
  mediaPlayer.refreshManifest((manifest) => {
584
606
  const mediaPresentationDuration = manifest && manifest.mediaPresentationDuration;
585
- if (!isNaN(mediaPresentationDuration)) {
607
+ if (isNaN(mediaPresentationDuration)) {
608
+ mediaPlayer.seek(seekToTime);
609
+ } else {
586
610
  DebugToolInstance.info("Stream ended. Clamping seek point to end of stream");
587
611
  mediaPlayer.seek(
588
612
  getClampedTime(seekToTime, { start: getSeekableRange().start, end: mediaPresentationDuration })
589
613
  );
590
- } else {
591
- mediaPlayer.seek(seekToTime);
592
614
  }
593
615
  });
594
616
  }
595
617
 
596
618
  function calculateSeekOffset(time) {
597
619
  function getClampedTimeForLive(time) {
598
- return Math.min(Math.max(time, 0), mediaPlayer.getDVRWindowSize() - playerSettings.streaming.liveDelay)
620
+ return Math.min(Math.max(time, 0), mediaPlayer.getDVRWindowSize() - Math.max(liveDelay, seekDurationPadding))
599
621
  }
600
622
 
601
623
  if (windowType === WindowTypes.SLIDING) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bigscreen-player",
3
- "version": "7.1.4",
3
+ "version": "8.0.0",
4
4
  "description": "Simplified media playback for bigscreen devices.",
5
5
  "main": "dist/esm/main.js",
6
6
  "browser": "dist/esm/main.js",
@@ -40,11 +40,11 @@
40
40
  "eslint-plugin-jest": "^27.1.4",
41
41
  "eslint-plugin-json": "^3.1.0",
42
42
  "eslint-plugin-sonarjs": "^0.16.0",
43
- "eslint-plugin-unicorn": "^44.0.2",
43
+ "eslint-plugin-unicorn": "^49.0.0",
44
44
  "husky": "^8.0.3",
45
45
  "jest": "^29.5.0",
46
46
  "jest-environment-jsdom": "^29.5.0",
47
- "jsdoc": "^3.6.4",
47
+ "jsdoc": "^4.0.2",
48
48
  "prettier": "^2.7.1",
49
49
  "rollup": "^2.54.0",
50
50
  "rollup-plugin-livereload": "^2.0.5",
@@ -54,7 +54,7 @@
54
54
  "rollup-plugin-visualizer": "^5.5.2"
55
55
  },
56
56
  "dependencies": {
57
- "dashjs": "github:bbc/dash.js#smp-v3.2.0-8",
57
+ "dashjs": "github:bbc/dash.js#smp-v4.7.1-0",
58
58
  "smp-imsc": "github:bbc/imscJS#v1.0.3"
59
59
  },
60
60
  "repository": {