define(["playbackManager","events"],function(playbackManager,events){"use strict";var orientationLocked;function onOrientationChangeSuccess(){orientationLocked=!0}function onOrientationChangeError(err){orientationLocked=!1,console.log("error locking orientation: "+err)}events.on(playbackManager,"playbackstart",function(e,player,state){player.isLocalPlayer&&!player.isExternalPlayer&&playbackManager.isPlayingVideo(player)&&function(orientation){var promise;try{return self.ScreenOrientation&&ScreenOrientation.lock?promise=ScreenOrientation.lock(orientation):screen.lockOrientation?promise=screen.lockOrientation(orientation):screen.orientation&&screen.orientation.lock&&(promise=screen.orientation.lock(orientation)),promise&&promise.then?promise:Promise.resolve()}catch(err){return Promise.reject(err)}}("landscape").then(onOrientationChangeSuccess,onOrientationChangeError)}),events.on(playbackManager,"playbackstop",function(e,playbackStopInfo){if(orientationLocked&&!playbackStopInfo.nextMediaType){try{self.ScreenOrientation&&ScreenOrientation.unlock?ScreenOrientation.unlock():screen.unlockOrientation?screen.unlockOrientation():screen.orientation&&screen.orientation.unlock&&screen.orientation.unlock()}catch(err){console.log("error unlocking orientation: "+err)}orientationLocked=!1}})});