Move query parameters to request body in SyncPlay

This commit is contained in:
Ionut Andrei Oanca 2020-11-28 14:24:01 +01:00
parent bbef2197dd
commit 308deaceba
3 changed files with 15 additions and 11 deletions

View File

@ -72,7 +72,7 @@ class Controller {
const sendPlayRequest = (items) => { const sendPlayRequest = (items) => {
const queue = items.map(item => item.Id); const queue = items.map(item => item.Id);
apiClient.requestSyncPlayPlay({ apiClient.requestSyncPlayPlay({
PlayingQueue: queue.join(','), PlayingQueue: queue,
PlayingItemPosition: options.startIndex ? options.startIndex : 0, PlayingItemPosition: options.startIndex ? options.startIndex : 0,
StartPositionTicks: options.startPositionTicks ? options.startPositionTicks : 0 StartPositionTicks: options.startPositionTicks ? options.startPositionTicks : 0
}); });
@ -135,7 +135,7 @@ class Controller {
Helper.translateItemsForPlayback(apiClient, options.items, options).then((items) => { Helper.translateItemsForPlayback(apiClient, options.items, options).then((items) => {
const itemIds = items.map(item => item.Id); const itemIds = items.map(item => item.Id);
apiClient.requestSyncPlayQueue({ apiClient.requestSyncPlayQueue({
ItemIds: itemIds.join(','), ItemIds: itemIds,
Mode: mode Mode: mode
}); });
}); });
@ -146,7 +146,7 @@ class Controller {
Helper.translateItemsForPlayback(apiClient, result.Items, options).then((items) => { Helper.translateItemsForPlayback(apiClient, result.Items, options).then((items) => {
const itemIds = items.map(item => item.Id); const itemIds = items.map(item => item.Id);
apiClient.requestSyncPlayQueue({ apiClient.requestSyncPlayQueue({
ItemIds: itemIds.join(','), ItemIds: itemIds,
Mode: mode Mode: mode
}); });
}); });

View File

@ -129,14 +129,19 @@ class PlaybackCore {
const now = this.timeSyncCore.localDateToRemote(currentTime); const now = this.timeSyncCore.localDateToRemote(currentTime);
const playlistItemId = this.manager.getQueueCore().getCurrentPlaylistItemId(); const playlistItemId = this.manager.getQueueCore().getCurrentPlaylistItemId();
const apiClient = this.manager.getApiClient(); const options = {
apiClient.requestSyncPlayBuffering({
When: now.toISOString(), When: now.toISOString(),
PositionTicks: currentPositionTicks, PositionTicks: currentPositionTicks,
IsPlaying: isPlaying, IsPlaying: isPlaying,
PlaylistItemId: playlistItemId, PlaylistItemId: playlistItemId
BufferingDone: !isBuffering };
});
const apiClient = this.manager.getApiClient();
if (isBuffering) {
apiClient.requestSyncPlayBuffering(options);
} else {
apiClient.requestSyncPlayReady(options);
}
} }
/** /**

View File

@ -176,12 +176,11 @@ class QueueCore {
const currentPositionTicks = Math.round(currentPosition * Helper.TicksPerMillisecond); const currentPositionTicks = Math.round(currentPosition * Helper.TicksPerMillisecond);
const isPlaying = playerWrapper.isPlaying(); const isPlaying = playerWrapper.isPlaying();
apiClient.requestSyncPlayBuffering({ apiClient.requestSyncPlayReady({
When: now.toISOString(), When: now.toISOString(),
PositionTicks: currentPositionTicks, PositionTicks: currentPositionTicks,
IsPlaying: isPlaying, IsPlaying: isPlaying,
PlaylistItemId: this.getCurrentPlaylistItemId(), PlaylistItemId: this.getCurrentPlaylistItemId()
BufferingDone: true
}); });
}).catch((error) => { }).catch((error) => {
console.error('Error while waiting for `playbackstart` event!', origin, error); console.error('Error while waiting for `playbackstart` event!', origin, error);