senza-sdk 4.3.1-4a01fcf.0 → 4.3.1-e113d43.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "senza-sdk",
3
- "version": "4.3.1-4a01fcf.0",
3
+ "version": "4.3.1-e113d43.0",
4
4
  "main": "./src/api.js",
5
5
  "description": "API for Senza application",
6
6
  "license": "MIT",
@@ -58,7 +58,6 @@
58
58
  }
59
59
  },
60
60
  "dependencies": {
61
- "shaka-player": "^4.12.5",
62
- "moment": "^2.30.1"
61
+ "shaka-player": "^4.12.5"
63
62
  }
64
63
  }
@@ -69,7 +69,6 @@ function setPlaybackInfo(playbackInfo) {
69
69
  * @typedef {Object} Config
70
70
  * @property {string} preferredAudioLanguage
71
71
  * @property {string} preferredSubtitlesLanguage
72
- * @property {number} minSuggestedPresentationDelay - minimal delay allowed for live playback in seconds
73
72
  * @property {boolean} autoPlay - (Not implemented yet) upon loading start playing automatically
74
73
  */
75
74
 
@@ -80,9 +79,9 @@ function setPlaybackInfo(playbackInfo) {
80
79
  * @fires ended
81
80
  * @fires error
82
81
  * @fires onloadmodechange
83
- * @fires playing
84
82
  * @fires seeking (Not implemented yet)
85
83
  * @fires seeked (Not implemented yet)
84
+ * @fires loadedmetadata (Not implemented yet)
86
85
  */
87
86
  class RemotePlayer extends RemotePlayerInterface {
88
87
  constructor() {
@@ -93,8 +92,7 @@ class RemotePlayer extends RemotePlayerInterface {
93
92
  */
94
93
  this._config = {
95
94
  preferredAudioLanguage: "",
96
- preferredSubtitlesLanguage: "",
97
- minSuggestedPresentationDelay: 0
95
+ preferredSubtitlesLanguage: ""
98
96
  };
99
97
  /**
100
98
  * @type {string}
@@ -527,10 +525,10 @@ class RemotePlayer extends RemotePlayerInterface {
527
525
 
528
526
  /** setting values for properties in the player configuration using an object.
529
527
  * If the config does not support a property this is a no-op.
530
- * @param {Config} props the object with all the different properties to change.
528
+ * @param {Object} props the object with all the different properties to change
531
529
  * @example
532
530
  * remotePlayer.configure({ preferredAudioLanguage: 'en-US' })
533
- * remotePlayer.configure({ minSuggestedPresentationDelay: 6 })
531
+ *
534
532
  * */
535
533
  configure(props) {
536
534
  Object.entries(props).forEach(([key, value]) => {
@@ -899,9 +897,6 @@ class RemotePlayer extends RemotePlayerInterface {
899
897
  this._updateSeekListeners(video);
900
898
  }
901
899
  this._videoElement = video;
902
-
903
- // Emit a custom event to notify about the attachment of the video element
904
- this.dispatchEvent(new Event("videoelementattached"));
905
900
  }
906
901
  }
907
902
 
@@ -917,7 +912,7 @@ class RemotePlayer extends RemotePlayerInterface {
917
912
  /** Tell the remote player to load the given URL.
918
913
  * @param {string} url url to load
919
914
  * @param {number} [position] start position in seconds (if not provided, start from beginning (VOD) or current time (LTV))
920
- * @returns {Promise}
915
+ * @returns {Promise}
921
916
  * @throws {RemotePlayerError} error object contains code & msg
922
917
  *
923
918
  * */
@@ -982,11 +977,6 @@ class RemotePlayer extends RemotePlayerInterface {
982
977
  message.action = "load";
983
978
  message.audioLanguage = audioLanguage;
984
979
  message.subtitlesLanguage = subtitlesLanguage;
985
- if (this.getConfiguration().minSuggestedPresentationDelay > 0) {
986
- message.cloudPlayerParams = {
987
- "mspd": this.getConfiguration().minSuggestedPresentationDelay
988
- };
989
- }
990
980
  } else {
991
981
  message.type = "setPlayableUri";
992
982
  }
@@ -2,8 +2,6 @@ import { shaka } from "../interface/senzaShakaPlayer";
2
2
 
3
3
  import { remotePlayer, lifecycle, getPlatformInfo } from "./api";
4
4
  import { sdkLogger, iso6393to1 } from "./utils";
5
- import moment from "moment";
6
-
7
5
 
8
6
  // Define custom error category
9
7
  shaka.util.Error.Category.SENZA_PLAYER_ERROR = 50;
@@ -74,9 +72,9 @@ export class SenzaShakaPlayer extends shaka.Player {
74
72
  * @private
75
73
  * @type {number}
76
74
  * @description Timeout in milliseconds to wait for playing event
77
- * @default 4000
75
+ * @default 3000
78
76
  */
79
- _playingTimeout = 4000;
77
+ _playingTimeout = 3000;
80
78
 
81
79
  /**
82
80
  * @private
@@ -91,7 +89,7 @@ export class SenzaShakaPlayer extends shaka.Player {
91
89
  * @description Whether to stop remote player on error
92
90
  * @default false
93
91
  */
94
- _shouldStopOnRemotePlayerError = false;
92
+ _shouldStopRemotePlayerOnError = false;
95
93
 
96
94
  /**
97
95
  * @private
@@ -282,15 +280,13 @@ export class SenzaShakaPlayer extends shaka.Player {
282
280
 
283
281
 
284
282
  /**
285
- * Handles errors received by remote player while waiting for the playing event.
286
- * The promise returned to the call for video element play will be rejected.
283
+ * Handles errors for play promises and remote player events.
287
284
  * @private
288
285
  * @param {Error} error - The error object.
289
286
  */
290
287
  _handlePlayPromiseError(error) {
291
288
 
292
289
  sdkLogger.error("Error while waiting for playing event:", error);
293
-
294
290
  if (this._playPromiseReject) {
295
291
  this._playPromiseReject(error);
296
292
  this._playPromiseResolve = null;
@@ -300,46 +296,6 @@ export class SenzaShakaPlayer extends shaka.Player {
300
296
  clearTimeout(this._playTimeoutId);
301
297
  this._playTimeoutId = null;
302
298
  }
303
-
304
- }
305
-
306
- /**
307
- * @private
308
- * @type {number}
309
- * @description Minimum suggested presentation delay in seconds
310
- * @default 15
311
- */
312
- _minSuggestedPresentationDelay = 15;
313
-
314
- /**
315
- * Modifies the suggestedPresentationDelay in the manifest text
316
- * @private
317
- * @param {string} manifestText - The MPD manifest text
318
- * @returns {string} - Modified manifest text , or undefined if no modification was done
319
- */
320
- _updateManifestDelayIfBelowMinimum(manifestText) {
321
- // Look for suggestedPresentationDelay attribute
322
- const match = manifestText.match(/suggestedPresentationDelay="([^"]+)"/);
323
- if (match) {
324
- const durationString = match[1];
325
- const duration = moment.duration(durationString);
326
- const currentDelay = duration.asSeconds();
327
-
328
- sdkLogger.info(`Found suggestedPresentationDelay in manifest: ${currentDelay.toFixed(3)}s`);
329
-
330
- if (currentDelay < this._minSuggestedPresentationDelay) {
331
- // Replace the value in the manifest text with 3 decimal places
332
- manifestText = manifestText.replace(
333
- /suggestedPresentationDelay="[^"]+"/,
334
- `suggestedPresentationDelay="PT${this._minSuggestedPresentationDelay.toFixed(3)}S"`
335
- );
336
- sdkLogger.info(`Updated manifest suggestedPresentationDelay to ${this._minSuggestedPresentationDelay.toFixed(3)}s`);
337
- return manifestText;
338
- }
339
- } else {
340
- sdkLogger.info("suggestedPresentationDelay is not defined at the manifest");
341
- }
342
- return undefined;
343
299
  }
344
300
 
345
301
  /**
@@ -369,38 +325,14 @@ export class SenzaShakaPlayer extends shaka.Player {
369
325
  const playTimeout = getPlatformInfo()?.sessionInfo?.settings?.["ui-streamer"]?.playingEventTimeout;
370
326
  this._playingTimeout = (playTimeout >= 0) ? playTimeout*1000 : this._playingTimeout;
371
327
 
372
- // Initialize minSuggestedPresentationDelay from UI settings or use default
373
- const uiSettings = getPlatformInfo()?.sessionInfo?.settings?.["ui-streamer"];
374
- if (uiSettings?.minSuggestedPresentationDelay !== undefined) {
375
- this._minSuggestedPresentationDelay = uiSettings.minSuggestedPresentationDelay;
376
- sdkLogger.info(`Using configured minSuggestedPresentationDelay: ${this._minSuggestedPresentationDelay}s`);
377
- }
378
-
379
328
  // if video element is provided, add the listeres here. In this case ,there is no need to call attach.
380
329
  if (videoElement) {
381
330
  this._attach(videoElement);
382
331
  sdkLogger.warn("SenzaShakaPlayer constructor Adding videoElement in the constructor is going to be deprecated in the future. Please use attach method instead.");
383
332
  }
384
333
 
385
- this.configure({
386
- manifest: {
387
- defaultPresentationDelay: this._minSuggestedPresentationDelay // in seconds
388
- }
389
- });
390
-
391
- remotePlayer.configure({
392
- minSuggestedPresentationDelay: this._minSuggestedPresentationDelay
393
- });
394
-
395
- this.addEventListener("buffering", () => {
396
- if (this.videoElement) {
397
- sdkLogger.info("Buffering at time:", this.videoElement.currentTime);
398
- }
399
- });
400
-
401
334
  }
402
335
 
403
-
404
336
  _attach(videoElement) {
405
337
  this.videoElement = videoElement;
406
338
 
@@ -624,12 +556,11 @@ export class SenzaShakaPlayer extends shaka.Player {
624
556
  const isCritical = this._isErrorCritical(remotePlayerErrorCode);
625
557
  const error = this._createSenzaError(remotePlayerErrorCode, message, isCritical);
626
558
  const errorMap = new Map();
627
- const shouldStopPlayback = this._shouldStopOnRemotePlayerError && this.videoElement && isCritical;
628
559
  errorMap.set("detail", error);
629
560
 
630
561
  // Check if we should stop playback - only for critical errors when configured
631
-
632
- if (shouldStopPlayback) {
562
+ if (this._shouldStopRemotePlayerOnError &&
563
+ this.videoElement && isCritical) {
633
564
  try {
634
565
  sdkLogger.warn("Stopping local player playback due to critical error");
635
566
  // Stop only local playback
@@ -637,11 +568,9 @@ export class SenzaShakaPlayer extends shaka.Player {
637
568
  } catch (stopError) {
638
569
  sdkLogger.error("Error while trying to stop video element playback:", stopError);
639
570
  }
640
- // Handle error while waiting for play event. If the error is not critical or the system is configured not to stop remote player on error,
641
- // the playback timeout will start the local playback
642
- this._handlePlayPromiseError(error);
643
571
  }
644
-
572
+ // Handle error while waiting for play event
573
+ this._handlePlayPromiseError(error);
645
574
  this.dispatchEvent(new shaka.util.FakeEvent("error", errorMap));
646
575
  }
647
576
 
@@ -679,30 +608,16 @@ export class SenzaShakaPlayer extends shaka.Player {
679
608
 
680
609
  // This callbakc will be activated when the manifest is loaded. It will trigger load of the remote player.
681
610
  // This will ensure that the remote player is loaded only after the manifest is loaded by local player.
682
- const responseFilterCallback = async (type, response) => {
683
- if (type === shaka.net.NetworkingEngine.RequestType.MANIFEST) {
611
+ const responseFilterCallback = async (type) => {
612
+ if (type === shaka.net.NetworkingEngine.RequestType.MANIFEST && !manifestLoadHandled) {
613
+ manifestLoadHandled = true;
684
614
  try {
685
- if (response.data && this._minSuggestedPresentationDelay > 0) {
686
- const manifestText = new TextDecoder().decode(response.data);
687
- const modifiedText = this._updateManifestDelayIfBelowMinimum(manifestText);
688
- if (modifiedText) {
689
- const responseData = new TextEncoder().encode(modifiedText).buffer;
690
- response.data = responseData;
691
- }
692
- }
615
+ await this._remotePlayerLoad(url, startTime);
616
+ remoteLoadResolver();
693
617
  } catch (error) {
694
- sdkLogger.error("Error processing manifest:", error);
618
+ remoteLoadRejecter(error);
695
619
  }
696
620
 
697
- if (!manifestLoadHandled) {
698
- manifestLoadHandled = true;
699
- try {
700
- await this._remotePlayerLoad(url, startTime);
701
- remoteLoadResolver();
702
- } catch (error) {
703
- remoteLoadRejecter(error);
704
- }
705
- }
706
621
  }
707
622
  };
708
623
 
@@ -765,14 +680,14 @@ export class SenzaShakaPlayer extends shaka.Player {
765
680
  /**
766
681
  * Override the configure method to add custom configuration handling
767
682
  * Supports the following additional configuration options:
768
- * - shouldStopOnRemotePlayerError: boolean - If true, local player will be stopped on remote player error
683
+ * - shouldStopRemotePlayerOnError: boolean - If true, remote player will be stopped on error
769
684
  *
770
685
  * @override
771
686
  * @param {Object} config - Configuration object to be merged with existing config
772
- * @param {boolean} [config.shouldStopOnRemotePlayerError=true] - Whether to stop local player on remote player error
687
+ * @param {boolean} [config.shouldStopRemotePlayerOnError=true] - Whether to stop remote player on error
773
688
  * @example
774
689
  * player.configure({
775
- * shouldStopOnRemotePlayerError: false, // Don't stop local playback on remote player error
690
+ * shouldStopRemotePlayerOnError: false, // Don't stop remote player on error
776
691
  * // ... other shaka configurations
777
692
  * });
778
693
  */
@@ -780,12 +695,12 @@ export class SenzaShakaPlayer extends shaka.Player {
780
695
  sdkLogger.log("configure player with: ", JSON.stringify(config));
781
696
 
782
697
  // Handle custom configuration
783
- if (config.shouldStopOnRemotePlayerError !== undefined) {
784
- this._shouldStopOnRemotePlayerError = !!config.shouldStopOnRemotePlayerError;
698
+ if (config.shouldStopRemotePlayerOnError !== undefined) {
699
+ this._shouldStopRemotePlayerOnError = !!config.shouldStopRemotePlayerOnError;
785
700
  // Remove our custom config so it doesn't get passed to parent
786
701
  // Use rest operator without creating a named variable for the removed property
787
702
  // eslint-disable-next-line no-unused-vars
788
- const { shouldStopOnRemotePlayerError, ...shakaConfig } = config;
703
+ const { shouldStopRemotePlayerOnError, ...shakaConfig } = config;
789
704
  config = shakaConfig;
790
705
  }
791
706
 
@@ -204,7 +204,6 @@ const setupSequence = (components, items) => {
204
204
  };
205
205
  methodInject(components, inject, (name) => name.startsWith("_") || name.startsWith("get"));
206
206
  handleKeys(items);
207
- playersEvents(components, items);
208
207
  sdkLogger.log("Sequence initialized.");
209
208
  };
210
209
 
@@ -258,37 +257,3 @@ export const showSequence = (visible = true) => {
258
257
  }
259
258
  container.style.visibility = visible ? "visible" : "hidden";
260
259
  };
261
- function playersEvents(components, items) {
262
- components.remotePlayer.addEventListener("videoelementattached", () => {
263
- const video = components.remotePlayer._videoElement;
264
- if (video && !video._devSequenceRateChangeHandler) {
265
- video._devSequenceRateChangeHandler = () => {
266
- items.push({
267
- component: "localPlayer",
268
- id: "ratechange=" + video.playbackRate,
269
- time: performance.now() - currentTime
270
- });
271
- };
272
- video.addEventListener("ratechange", video._devSequenceRateChangeHandler);
273
- }
274
-
275
- if (video && !video._devSequencePlayingHandler) {
276
- video._devSequencePlayingHandler = () => {
277
- items.push({
278
- component: "localPlayer",
279
- id: "playing event",
280
- time: performance.now() - currentTime
281
- });
282
- };
283
- video.addEventListener("playing", video._devSequencePlayingHandler);
284
- }
285
- });
286
- components.remotePlayer.addEventListener("playing", () => {
287
- items.push({
288
- component: "remotePlayer",
289
- id: "playing event",
290
- time: performance.now() - currentTime
291
- });
292
- });
293
- }
294
-