senza-sdk 4.2.53 → 4.2.54-c5f8bb3.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.53",
3
+ "version": "4.2.54-c5f8bb3.0",
4
4
  "main": "./src/api.js",
5
5
  "description": "API for Senza application",
6
6
  "license": "MIT",
package/src/lifecycle.js CHANGED
@@ -551,6 +551,10 @@ 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
+ }
554
558
  return new Promise((resolve, reject) => {
555
559
  const FCID = getFCID();
556
560
  const logger = sdkLogger.withFields({ FCID });
@@ -618,10 +622,6 @@ class Lifecycle extends EventTarget {
618
622
 
619
623
  _moveToBackground() {
620
624
  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 (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
- }
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) {
719
719
  remotePlayer._targetSeekPlayingState = TargetPlayingState.PLAYING_ABR;
720
720
  return Promise.resolve(true);
721
721
  }
@@ -1454,15 +1454,15 @@ class RemotePlayer extends EventTarget {
1454
1454
  async _atomicSeek() {
1455
1455
  sdkLogger.info("Seeking: local video element seeking start while isPLaying=", this._isPlaying);
1456
1456
 
1457
- // Initialize the target playing state unless changed during the seek process
1458
- // In the future, we should allow for seeking in background. Currently, there's no
1459
- // way to know when the web application will call moveToForeground (i.e Before/After seek)
1460
- // Therefore, for now, we will assume the target is either paused or playing in ui unless
1461
- // specifically receiving a moveToBackground during the process.
1462
- // if (this._isPlaying && (lifecycle.state === lifecycle.UiState.BACKGROUND || lifecycle.state === lifecycle.UiState.IN_TRANSITION_TO_BACKGROUND)) {
1463
- // this._targetSeekPlayingState = TargetPlayingState.PLAYING_ABR;
1464
- // }
1465
- this._targetSeekPlayingState = this._isPlaying ? TargetPlayingState.PLAYING_UI : TargetPlayingState.PAUSED;
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
+ }
1466
1466
 
1467
1467
  // The platform could be currently syncing audio/video using playback rate. Reset when performing seek.
1468
1468
  if (this._videoElement) {
@@ -1529,11 +1529,13 @@ class RemotePlayer extends EventTarget {
1529
1529
 
1530
1530
  // If in TargetPlayingState.PAUSE, no need to resume.
1531
1531
  // Resume without awaiting to avoid blocking the seek process anymore
1532
- // In case where we aborted, we don't want to resume playback.
1532
+ // In case where we aborted (new load or unload called), we don't want to resume playback.
1533
1533
  if (!this._abortSeeking) {
1534
1534
  if (this._targetSeekPlayingState === TargetPlayingState.PLAYING_UI) {
1535
1535
  this._play();
1536
1536
  } else if (this._targetSeekPlayingState === TargetPlayingState.PLAYING_ABR) {
1537
+ // When moving back to background, we need to put the remote player back into play mode
1538
+ this._changePlayMode(true);
1537
1539
  lifecycle._moveToBackground();
1538
1540
  }
1539
1541
  }