define(["./../common/playback/playbackmanager.js","./../emby-apiclient/events.js"],function(_playbackmanager,_events){_events.default.on(_playbackmanager.default,"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 resumePositionTicks,state=_playbackmanager.default.getPlayerState(oldPlayer),item=state.NowPlayingItem;if(item)return resumePositionTicks=(state.PlayState||{}).PositionTicks||0,console.log("stopping player"),_playbackmanager.default.stop(oldPlayer).then(function(){console.log("player stopped"),_playbackmanager.default.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")})});