Package com.brightcove.player.video360
Class RotationMonitor
- java.lang.Object
-
- com.brightcove.player.video360.RotationMonitor
-
public class RotationMonitor extends java.lang.Object
Rotation monitor can be use watch for device rotation changes. It usesSensor.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 sensorsSensor.TYPE_ACCELEROMETER
,Sensor.TYPE_GYROSCOPE
andSensor.TYPE_MAGNETIC_FIELD
to detect the rotation changes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
RotationMonitor.Listener
Defines the contract of listener that can receive notifications about device rotation changes.
-
Constructor Summary
Constructors Constructor Description RotationMonitor(android.content.Context context)
Constructs a new rotation monitor for the given context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RotationMonitor.Listener
getListener()
Gets reference to the current listener that will be notified when an rotation change is detected.int
getRotation()
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
startTracking()
Starts the rotation monitor to start tracking for device rotation changes.void
stopTracking()
Stops the rotation monitor.
-
-
-
Method Detail
-
getListener
@Nullable public RotationMonitor.Listener getListener()
Gets reference to the current listener that will be notified when an rotation change is detected.- Returns:
- reference the rotation listener.
-
setListener
public void setListener(@Nullable RotationMonitor.Listener listener)
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.
-
-