define(["events","playbackManager"],function(events,playbackManager){"use strict";events.on(playbackManager,"playerchange",function(e,newPlayer,newTarget,oldPlayer){if(oldPlayer)if(newPlayer)if(oldPlayer.isLocalPlayer&&newPlayer.isLocalPlayer)console.log("Skipping remote control autoplay because both old and new players are local");else{if(!newPlayer.isLocalPlayer)return function(oldPlayer,newPlayer){console.log("transferPlayback");var state=playbackManager.getPlayerState(oldPlayer),item=state.NowPlayingItem;if(item){var resumePositionTicks=(state.PlayState||{}).PositionTicks||0;return console.log("stopping player"),playbackManager.stop(oldPlayer).then(function(){console.log("player stopped"),playbackManager.play({ids:[item.Id],serverId:item.ServerId,startPositionTicks:resumePositionTicks},newPlayer)})}console.log("aborting transferPlayback because item is null")}(oldPlayer,newPlayer);console.log("Skipping remote control autoplay because newPlayer is a local player")}else console.log("Skipping remote control autoplay because new player is null")})});