Package com.brightcove.player.video360
Class RotationMonitor
java.lang.Object
com.brightcove.player.video360.RotationMonitor
Rotation monitor can be use watch for device rotation changes. It uses
Sensor.TYPE_ROTATION_VECTOR
sensor if available to detect device rotation changes. If the
sensor is not available then the rotation monitor will attempt use the sensors
Sensor.TYPE_ACCELEROMETER
, Sensor.TYPE_GYROSCOPE
and Sensor.TYPE_MAGNETIC_FIELD
to detect the rotation changes.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Defines the contract of listener that can receive notifications about device rotation changes. -
Constructor Summary
ConstructorDescriptionRotationMonitor
(android.content.Context context) Constructs a new rotation monitor for the given context. -
Method Summary
Modifier and TypeMethodDescriptionGets reference to the current listener that will be notified when an rotation change is detected.int
Returns the rotation of the screen from its "natural" rotation.void
setListener
(RotationMonitor.Listener listener) Sets reference to the current listener that must be notified when an rotation change is detected.void
Starts the rotation monitor to start tracking for device rotation changes.void
Stops the rotation monitor.
-
Constructor Details
-
RotationMonitor
public RotationMonitor(android.content.Context context) Constructs a new rotation monitor for the given context.- Parameters:
context
- the context of the view that owns this rotation monitor.
-
-
Method Details
-
getListener
Gets reference to the current listener that will be notified when an rotation change is detected.- Returns:
- reference the rotation listener.
-
setListener
Sets reference to the current listener that must be notified when an rotation change is detected.- Parameters:
listener
- reference the rotation listener.
-
startTracking
public void startTracking()Starts the rotation monitor to start tracking for device rotation changes. -
stopTracking
public void stopTracking()Stops the rotation monitor. -
getRotation
public int getRotation()Returns the rotation of the screen from its "natural" rotation. The returned value may be Surface.ROTATION_0 (no rotation), Surface.ROTATION_90, Surface.ROTATION_180, or Surface.ROTATION_270. For example, if a device has a naturally tall screen, and the user has turned it on its side to go into a landscape rotation, the value returned here may be either Surface.ROTATION_90 or Surface.ROTATION_270 depending on the direction it was turned. The angle is the rotation of the drawn graphics on the screen, which is the opposite direction of the physical rotation of the device. For example, if the device is rotated 90 degrees counter-clockwise, to compensate rendering will be rotated by 90 degrees clockwise and thus the returned value here will be Surface.ROTATION_90.- Returns:
- the current rotation.
-