Skip to content

Commit

Permalink
Fix scheduleWhilePaused not working (#3785)
Browse files Browse the repository at this point in the history
* Fix scheduleWhilePaused not working
  • Loading branch information
chanh1964 authored Oct 12, 2021
1 parent ea3d3b9 commit c1f889d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/streaming/controllers/ScheduleController.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ function ScheduleController(config) {
*/
function _shouldClearScheduleTimer() {
try {
return (((type === Constants.TEXT) && !textController.isTextEnabled()));
return (((type === Constants.TEXT) && !textController.isTextEnabled()) ||
(playbackController.isPaused() && (!playbackController.getStreamController().getInitialPlayback() || !playbackController.getStreamController().getAutoPlay()) && !settings.get().streaming.scheduling.scheduleWhilePaused));
} catch (e) {
return false;
}
Expand Down
27 changes: 24 additions & 3 deletions src/streaming/controllers/StreamController.js
Original file line number Diff line number Diff line change
Expand Up @@ -752,11 +752,14 @@ function StreamController() {
* @private
*/
function _onPlaybackStarted( /*e*/) {
logger.debug('[onPlaybackStarted]');
if (!initialPlayback && isPaused) {
isPaused = false;
logger.debug('[onPlaybackStarted]');
if (!initialPlayback && isPaused) {
createPlaylistMetrics(PlayList.RESUME_FROM_PAUSE_START_REASON);
}
if (initialPlayback) {
initialPlayback = false;
}
isPaused = false;
}

/**
Expand Down Expand Up @@ -984,6 +987,22 @@ function StreamController() {
return activeStream;
}

/**
* Initial playback indicates if we have called play() for the first time yet.
* @return {*}
*/
function getInitialPlayback() {
return initialPlayback;
}

/**
* Auto Play indicates if the stream starts automatically as soon as it is initialized.
* @return {boolean}
*/
function getAutoPlay() {
return autoPlay;
}

/**
* Called once the first stream has been initialized. We only use this function to seek to the right start time.
* @return {number}
Expand Down Expand Up @@ -1504,6 +1523,8 @@ function StreamController() {
getHasMediaOrInitialisationError,
getStreams,
getActiveStream,
getInitialPlayback,
getAutoPlay,
reset
};

Expand Down

0 comments on commit c1f889d

Please sign in to comment.