mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
fix remote control stopping playback
This commit is contained in:
parent
1f1475c2f1
commit
6c735c55a9
11 changed files with 84 additions and 60 deletions
|
@ -315,7 +315,7 @@
|
|||
|
||||
if (!this.session) {
|
||||
console.log("no session");
|
||||
return;
|
||||
return Promise.reject();
|
||||
}
|
||||
|
||||
// Convert the items to smaller stubs to send the minimal amount of information
|
||||
|
@ -330,7 +330,7 @@
|
|||
};
|
||||
});
|
||||
|
||||
this.sendMessage({
|
||||
return this.sendMessage({
|
||||
options: options,
|
||||
command: command
|
||||
});
|
||||
|
@ -359,11 +359,15 @@
|
|||
message.maxBitrate = bitrateSetting;
|
||||
}
|
||||
|
||||
require(['chromecasthelpers'], function (chromecasthelpers) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
chromecasthelpers.getServerAddress(ApiClient).then(function (serverAddress) {
|
||||
message.serverAddress = serverAddress;
|
||||
player.sendMessageInternal(message);
|
||||
require(['chromecasthelpers'], function (chromecasthelpers) {
|
||||
|
||||
chromecasthelpers.getServerAddress(ApiClient).then(function (serverAddress) {
|
||||
message.serverAddress = serverAddress;
|
||||
player.sendMessageInternal(message).then(resolve, reject);
|
||||
|
||||
}, reject);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@ -374,6 +378,7 @@
|
|||
//console.log(message);
|
||||
|
||||
this.session.sendMessage(messageNamespace, message, this.onPlayCommandSuccess.bind(this), this.errorHandler);
|
||||
return Promise.resolve();
|
||||
};
|
||||
|
||||
CastPlayer.prototype.onPlayCommandSuccess = function () {
|
||||
|
@ -541,22 +546,22 @@
|
|||
|
||||
self.play = function (options) {
|
||||
|
||||
Dashboard.getCurrentUser().then(function (user) {
|
||||
return Dashboard.getCurrentUser().then(function (user) {
|
||||
|
||||
if (options.items) {
|
||||
|
||||
self.playWithCommand(options, 'PlayNow');
|
||||
return self.playWithCommand(options, 'PlayNow');
|
||||
|
||||
} else {
|
||||
|
||||
self.getItemsForPlayback({
|
||||
return self.getItemsForPlayback({
|
||||
|
||||
Ids: options.ids.join(',')
|
||||
|
||||
}).then(function (result) {
|
||||
|
||||
options.items = result.Items;
|
||||
self.playWithCommand(options, 'PlayNow');
|
||||
return self.playWithCommand(options, 'PlayNow');
|
||||
|
||||
});
|
||||
}
|
||||
|
@ -568,16 +573,14 @@
|
|||
self.playWithCommand = function (options, command) {
|
||||
|
||||
if (!options.items) {
|
||||
ApiClient.getItem(Dashboard.getCurrentUserId(), options.ids[0]).then(function (item) {
|
||||
return ApiClient.getItem(Dashboard.getCurrentUserId(), options.ids[0]).then(function (item) {
|
||||
|
||||
options.items = [item];
|
||||
self.playWithCommand(options, command);
|
||||
return self.playWithCommand(options, command);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
castPlayer.loadMedia(options, command);
|
||||
return castPlayer.loadMedia(options, command);
|
||||
};
|
||||
|
||||
self.unpause = function () {
|
||||
|
|
|
@ -460,22 +460,24 @@
|
|||
});
|
||||
};
|
||||
|
||||
function doWithPlaybackValidation(player, fn) {
|
||||
function validatePlayback(player) {
|
||||
|
||||
if (!player.isLocalPlayer) {
|
||||
fn();
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
requirejs(["registrationServices"], function (registrationServices) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
self.playbackTimeLimitMs = null;
|
||||
requirejs(["registrationServices"], function (registrationServices) {
|
||||
|
||||
registrationServices.validateFeature('playback').then(fn, function () {
|
||||
self.playbackTimeLimitMs = null;
|
||||
|
||||
self.playbackTimeLimitMs = lockedTimeLimitMs;
|
||||
startAutoStopTimer();
|
||||
fn();
|
||||
registrationServices.validateFeature('playback').then(resolve, function () {
|
||||
|
||||
self.playbackTimeLimitMs = lockedTimeLimitMs;
|
||||
startAutoStopTimer();
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -525,16 +527,16 @@
|
|||
|
||||
if (options.enableRemotePlayers === false) {
|
||||
if (!currentPlayer.isLocalPlayer) {
|
||||
return;
|
||||
return Promise.reject();
|
||||
}
|
||||
}
|
||||
|
||||
doWithPlaybackValidation(currentPlayer, function () {
|
||||
return validatePlayback(currentPlayer).then(function () {
|
||||
if (typeof (options) === 'string') {
|
||||
options = { ids: [options] };
|
||||
}
|
||||
|
||||
currentPlayer.play(options);
|
||||
return currentPlayer.play(options);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -545,7 +547,7 @@
|
|||
id = id.Id;
|
||||
}
|
||||
|
||||
doWithPlaybackValidation(currentPlayer, function () {
|
||||
validatePlayback(currentPlayer).then(function () {
|
||||
currentPlayer.shuffle(id);
|
||||
});
|
||||
};
|
||||
|
@ -557,7 +559,7 @@
|
|||
id = id.Id;
|
||||
}
|
||||
|
||||
doWithPlaybackValidation(currentPlayer, function () {
|
||||
validatePlayback(currentPlayer).then(function () {
|
||||
currentPlayer.instantMix(id);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -434,26 +434,26 @@ define(['appSettings', 'userSettings', 'appStorage', 'datetime'], function (appS
|
|||
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
Dashboard.getCurrentUser().then(function (user) {
|
||||
return Dashboard.getCurrentUser().then(function (user) {
|
||||
|
||||
if (options.items) {
|
||||
|
||||
translateItemsForPlayback(options.items, true).then(function (items) {
|
||||
return translateItemsForPlayback(options.items, true).then(function (items) {
|
||||
|
||||
self.playWithIntros(items, options, user);
|
||||
return self.playWithIntros(items, options, user);
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
self.getItemsForPlayback({
|
||||
return self.getItemsForPlayback({
|
||||
|
||||
Ids: options.ids.join(',')
|
||||
|
||||
}).then(function (result) {
|
||||
|
||||
translateItemsForPlayback(result.Items, true).then(function (items) {
|
||||
return translateItemsForPlayback(result.Items, true).then(function (items) {
|
||||
|
||||
self.playWithIntros(items, options, user);
|
||||
return self.playWithIntros(items, options, user);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -489,6 +489,8 @@ define(['appSettings', 'userSettings', 'appStorage', 'datetime'], function (appS
|
|||
});
|
||||
|
||||
});
|
||||
// Todo: rework above methods to use promises
|
||||
return Promise.resolve();
|
||||
};
|
||||
|
||||
function getOptimalMediaSource(mediaType, versions) {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
remoteOptions.startPositionTicks = options.startPositionTicks;
|
||||
}
|
||||
|
||||
ApiClient.sendPlayCommand(sessionId, remoteOptions);
|
||||
return ApiClient.sendPlayCommand(sessionId, remoteOptions);
|
||||
}
|
||||
|
||||
function sendPlayStateCommand(command, options) {
|
||||
|
@ -57,7 +57,7 @@
|
|||
|
||||
self.play = function (options) {
|
||||
|
||||
sendPlayCommand(options, 'PlayNow');
|
||||
return sendPlayCommand(options, 'PlayNow');
|
||||
};
|
||||
|
||||
self.shuffle = function (id) {
|
||||
|
|
|
@ -1441,11 +1441,11 @@ var AppInfo = {};
|
|||
if (options.fullscreen === false) {
|
||||
// theme backdrops - not supported
|
||||
if (!options.items || options.items[0].MediaType == 'Video') {
|
||||
return;
|
||||
return Promise.reject();
|
||||
}
|
||||
}
|
||||
|
||||
MediaController.play(options);
|
||||
return MediaController.play(options);
|
||||
},
|
||||
queue: function (options) {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue