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 item,resumePositionTicks,state=_playbackmanager.default.getPlayerState(oldPlayer);return state.IsBackgroundPlayback?_playbackmanager.default.stop(oldPlayer):(item=state.NowPlayingItem)?(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)})):void 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")})});