You are not logged in.

1

Friday, March 4th 2016, 5:16pm

Locking the screen/device orientation (on Android)

Hi,

modern Android browsers (Chrome & Firefox) are supporting the possibility to lock the screen orientation in fullscreen mode.

Here an action to use that from krpano:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
<action name="lock_screen_orientation" type="Javascript"><![CDATA[

  var screen_orientation_api = typeof(screen.orientation) == "object" && screen.orientation.type && screen.orientation.lock;
   		 
  var current_orientation = "" + (screen_orientation_api ? screen.orientation.type : (screen.orientation || screen.mozOrientation));
  var target_orientation = current_orientation.indexOf("landscape") >= 0 ? current_orientation : "landscape";
   	 
  if (screen.lockOrientation) screen.lockOrientation(target_orientation);
  else if (screen.mozLockOrientation) screen.mozLockOrientation(target_orientation);
  else if (screen_orientation_api) screen.orientation.lock(target_orientation);

]]></action>


Call that action in the onenterfullscreen event:

Source code

1
<events onenterfullscreen="lock_screen_orientation();" devices="android" />


In the next release this functionality will be also integrated in the WebVR plugin.

Best regards,
Klaus