Skip to content

Commit

Permalink
Move stop function to playbackManager
Browse files Browse the repository at this point in the history
  • Loading branch information
YouKnowBlom committed Jun 10, 2020
1 parent 03dd0b2 commit d36a8c7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/components/commandHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class commandHandler {
}

StopHandler() {
stop();
this.playerManager.stop();
}

PlayPauseHandler() {
Expand Down
28 changes: 1 addition & 27 deletions src/components/maincontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ mgr.defaultOnPause = function (event) {
mgr.addEventListener('PAUSE', mgr.defaultOnPause);

mgr.defaultOnStop = function (event) {
stop();
playbackMgr.stop();
};
mgr.addEventListener('ABORT', mgr.defaultOnStop);

Expand All @@ -153,32 +153,6 @@ mgr.addEventListener('ENDED', function () {
}
});

export function stop(nextMode) {

$scope.playNextItem = nextMode ? true : false;
jellyfinActions.stop($scope);

var reportingParams = getReportingParams($scope);

var promise;

jellyfinActions.stopPingInterval();

if (reportingParams.ItemId) {
promise = jellyfinActions.reportPlaybackStopped($scope, reportingParams);
}

window.mediaManager.stop();

window.playlist = [];
window.currentPlaylistIndex = -1;
jellyfinActions.displayUserInfo($scope, $scope.serverAddress, $scope.accessToken, $scope.userId);

promise = promise || Promise.resolve();

return promise;
}

window.castReceiverContext.addEventListener(cast.framework.system.EventType.SYSTEM_VOLUME_CHANGED, function (event) {
console.log("### Cast Receiver Manager - System Volume Changed : " + JSON.stringify(event.data));

Expand Down
31 changes: 29 additions & 2 deletions src/components/playbackManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
getIntros,
setAppStatus,
broadcastConnectionErrorMessage,
tagItems
tagItems,
getReportingParams
} from "../helpers";

import {
Expand Down Expand Up @@ -100,7 +101,7 @@ export class playbackManager {

if (stopPlayer) {

stop("none").then(callback);
this.stop("none").then(callback);
} else {
callback();
}
Expand Down Expand Up @@ -142,4 +143,30 @@ export class playbackManager {
}, broadcastConnectionErrorMessage);
});
}

stop(nextMode) {

$scope.playNextItem = nextMode ? true : false;
jellyfinActions.stop($scope);

var reportingParams = getReportingParams($scope);

var promise;

jellyfinActions.stopPingInterval();

if (reportingParams.ItemId) {
promise = jellyfinActions.reportPlaybackStopped($scope, reportingParams);
}

this.playerManager.stop();

this.activePlaylist = [];
this.activePlaylistIndex = -1;
jellyfinActions.displayUserInfo($scope, $scope.serverAddress, $scope.accessToken, $scope.userId);

promise = promise || Promise.resolve();

return promise;
}
}

0 comments on commit d36a8c7

Please sign in to comment.