senza-sdk 4.2.54-b3a1f15.0 → 4.2.54-d09bbe7.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.2.54-b3a1f15.0",
3
+ "version": "4.2.54-d09bbe7.0",
4
4
  "main": "./src/api.js",
5
5
  "description": "API for Senza application",
6
6
  "license": "MIT",
package/src/lifecycle.js CHANGED
@@ -551,10 +551,6 @@ class Lifecycle extends EventTarget {
551
551
  alarmManager._moveToForegroundCalled();
552
552
  const FCID = getFCID();
553
553
  if (this._remotePlayerApiVersion >= 2) {
554
- // Only update to playing UI if we started seeking in ABR. But, if we are seeking while already paused, keep the target seek state as is.
555
- if (remotePlayer._isSeekingByApplication && remotePlayer._targetSeekPlayingState === TargetPlayingState.PLAYING_ABR) {
556
- remotePlayer._targetSeekPlayingState = TargetPlayingState.PLAYING_UI;
557
- }
558
554
  return new Promise((resolve, reject) => {
559
555
  const FCID = getFCID();
560
556
  const logger = sdkLogger.withFields({ FCID });
@@ -622,6 +618,10 @@ class Lifecycle extends EventTarget {
622
618
 
623
619
  _moveToBackground() {
624
620
  if (window.cefQuery) {
621
+ if (this._inTransition || this._state === this.UiState.BACKGROUND || this._state === this.UiState.IN_TRANSITION_TO_BACKGROUND) {
622
+ sdkLogger.warn(`lifecycle moveToBackground: No need to transition to background, state: ${this._state} transition: ${this._inTransition}`);
623
+ return Promise.resolve(false);
624
+ }
625
625
  // If audio sync is disabled, we only need to sync before remote player starts playing
626
626
  if (!isAudioSyncConfigured()) {
627
627
  remotePlayer._syncRemotePlayerWithLocalPlayer();
@@ -710,12 +710,12 @@ class Lifecycle extends EventTarget {
710
710
  * Failure to process the moveToBackground command will result in the promise being rejected.
711
711
  */
712
712
  moveToBackground() {
713
- if (window.cefQuery) {
714
- if (this._inTransition || this._state === this.UiState.BACKGROUND || this._state === this.UiState.IN_TRANSITION_TO_BACKGROUND) {
715
- sdkLogger.warn(`lifecycle moveToBackground: No need to transition to background, state: ${this._state} transition: ${this._inTransition}`);
716
- return Promise.resolve(false);
717
- }
718
- if (remotePlayer._isSeekingByApplication) {
713
+ if (remotePlayer._isSeekingByApplication) {
714
+ if (window.cefQuery) {
715
+ if (this._inTransition || this._state === this.UiState.BACKGROUND || this._state === this.UiState.IN_TRANSITION_TO_BACKGROUND) {
716
+ sdkLogger.warn(`lifecycle moveToBackground: No need to transition to background, state: ${this._state} transition: ${this._inTransition}`);
717
+ return Promise.resolve(false);
718
+ }
719
719
  remotePlayer._targetSeekPlayingState = TargetPlayingState.PLAYING_ABR;
720
720
  return Promise.resolve(true);
721
721
  }
@@ -1434,10 +1434,12 @@ class RemotePlayer extends EventTarget {
1434
1434
  }
1435
1435
  }
1436
1436
 
1437
- if (this._remotePlayerApiVersion >= 2 && !this._isSeekingByPlatform && !this._isSeekingByApplication) {
1437
+ // Only allow seeking in foreground. Still ignore the initialized local player seeking event above
1438
+ if (this._remotePlayerApiVersion >= 2 && !this._isSeekingByPlatform && !this._isSeekingByApplication &&
1439
+ (lifecycle.state === lifecycle.UiState.FOREGROUND || lifecycle.state === lifecycle.UiState.IN_TRANSITION_TO_FOREGROUND)) {
1438
1440
  this._atomicSeek();
1439
1441
  } else {
1440
- sdkLogger.info(`Seeking: skipping seeking event to currentTime=${this._videoElement.currentTime} internalSeek=${this._isSeekingByPlatform} localPlayerSeek=${this._isSeekingByApplication}`);
1442
+ sdkLogger.info(`Seeking: skipping seeking event to currentTime=${playbackPosition} internalSeek=${this._isSeekingByPlatform} localPlayerSeek=${this._isSeekingByApplication} state="${lifecycle.state}"`);
1441
1443
  }
1442
1444
  }
1443
1445
 
@@ -1454,15 +1456,15 @@ class RemotePlayer extends EventTarget {
1454
1456
  async _atomicSeek() {
1455
1457
  sdkLogger.info("Seeking: local video element seeking start while isPLaying=", this._isPlaying);
1456
1458
 
1457
- if (this._isPlaying) {
1458
- if (lifecycle.state === lifecycle.UiState.BACKGROUND || lifecycle.state === lifecycle.UiState.IN_TRANSITION_TO_BACKGROUND) {
1459
- this._targetSeekPlayingState = TargetPlayingState.PLAYING_ABR;
1460
- } else {
1461
- this._targetSeekPlayingState = TargetPlayingState.PLAYING_UI;
1462
- }
1463
- } else {
1464
- this._targetSeekPlayingState = TargetPlayingState.PAUSED;
1465
- }
1459
+ // Initialize the target playing state unless changed during the seek process
1460
+ // In the future, we should allow for seeking in background. Currently, there's no
1461
+ // way to know when the web application will call moveToForeground (i.e Before/After seek)
1462
+ // Therefore, for now, we will assume the target is either paused or playing in ui unless
1463
+ // specifically receiving a moveToBackground during the process.
1464
+ // if (this._isPlaying && (lifecycle.state === lifecycle.UiState.BACKGROUND || lifecycle.state === lifecycle.UiState.IN_TRANSITION_TO_BACKGROUND)) {
1465
+ // this._targetSeekPlayingState = TargetPlayingState.PLAYING_ABR;
1466
+ // }
1467
+ this._targetSeekPlayingState = this._isPlaying ? TargetPlayingState.PLAYING_UI : TargetPlayingState.PAUSED;
1466
1468
 
1467
1469
  // The platform could be currently syncing audio/video using playback rate. Reset when performing seek.
1468
1470
  if (this._videoElement) {
@@ -1529,7 +1531,7 @@ class RemotePlayer extends EventTarget {
1529
1531
 
1530
1532
  // If in TargetPlayingState.PAUSE, no need to resume.
1531
1533
  // Resume without awaiting to avoid blocking the seek process anymore
1532
- // In case where we aborted (new load or unload called), we don't want to resume playback.
1534
+ // In case where we aborted, we don't want to resume playback.
1533
1535
  if (!this._abortSeeking) {
1534
1536
  if (this._targetSeekPlayingState === TargetPlayingState.PLAYING_UI) {
1535
1537
  this._play();