mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
move emby-webcomponents to components and reflect paths
This commit is contained in:
parent
e91cbf8438
commit
6ddc62857d
275 changed files with 20 additions and 20 deletions
47
src/components/playback/remotecontrolautoplay.js
Normal file
47
src/components/playback/remotecontrolautoplay.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
define(['events', 'playbackManager'], function (events, playbackManager) {
|
||||
'use strict';
|
||||
|
||||
function transferPlayback(oldPlayer, newPlayer) {
|
||||
|
||||
var state = playbackManager.getPlayerState(oldPlayer);
|
||||
|
||||
var item = state.NowPlayingItem;
|
||||
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
|
||||
var playState = state.PlayState || {};
|
||||
var resumePositionTicks = playState.PositionTicks || 0;
|
||||
|
||||
playbackManager.stop(oldPlayer).then(function () {
|
||||
|
||||
playbackManager.play({
|
||||
ids: [item.Id],
|
||||
serverId: item.ServerId,
|
||||
startPositionTicks: resumePositionTicks
|
||||
|
||||
}, newPlayer);
|
||||
});
|
||||
}
|
||||
|
||||
events.on(playbackManager, 'playerchange', function (e, newPlayer, newTarget, oldPlayer) {
|
||||
|
||||
if (!oldPlayer || !newPlayer) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!oldPlayer.isLocalPlayer) {
|
||||
console.log('Skipping remote control autoplay because oldPlayer is not a local player');
|
||||
return;
|
||||
}
|
||||
|
||||
if (newPlayer.isLocalPlayer) {
|
||||
console.log('Skipping remote control autoplay because newPlayer is a local player');
|
||||
return;
|
||||
}
|
||||
|
||||
transferPlayback(oldPlayer, newPlayer);
|
||||
});
|
||||
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue