Skip to content

Commit

Permalink
Fall back to TYPE_ROTATION_VECTOR if TYPE_GAME_ROTATION_VECTOR unavai…
Browse files Browse the repository at this point in the history
…lable

Issue: #5119
PiperOrigin-RevId: 222978448
  • Loading branch information
ojw28 committed Nov 27, 2018
1 parent 38c5329 commit 017923e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
3 changes: 3 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
([#5063](https://github.com/google/ExoPlayer/issues/5063)).
* MP4: Support Opus and FLAC in the MP4 container, and in DASH
([#4883](https://github.com/google/ExoPlayer/issues/4883)).
* Spherical video: Fall back to `TYPE_ROTATION_VECTOR` if
`TYPE_GAME_ROTATION_VECTOR` is unavailable
([#5119](https://github.com/google/ExoPlayer/issues/5119)).
* Support seeking for a wider range of MPEG-TS streams
([#5097](https://github.com/google/ExoPlayer/issues/5097)).
* DASH: Fix detecting the end of live events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,18 @@ public SphericalSurfaceView(Context context, @Nullable AttributeSet attributeSet
// Configure sensors and touch.
sensorManager =
(SensorManager) Assertions.checkNotNull(context.getSystemService(Context.SENSOR_SERVICE));
// TYPE_GAME_ROTATION_VECTOR is the easiest sensor since it handles all the complex math for
// fusion. It's used instead of TYPE_ROTATION_VECTOR since the latter uses the magnetometer on
// devices. When used indoors, the magnetometer can take some time to settle depending on the
// device and amount of metal in the environment.
int type = Util.SDK_INT >= 18 ? Sensor.TYPE_GAME_ROTATION_VECTOR : Sensor.TYPE_ROTATION_VECTOR;
orientationSensor = sensorManager.getDefaultSensor(type);
Sensor orientationSensor = null;
if (Util.SDK_INT >= 18) {
// TYPE_GAME_ROTATION_VECTOR is the easiest sensor since it handles all the complex math for
// fusion. It's used instead of TYPE_ROTATION_VECTOR since the latter uses the magnetometer on
// devices. When used indoors, the magnetometer can take some time to settle depending on the
// device and amount of metal in the environment.
orientationSensor = sensorManager.getDefaultSensor(Sensor.TYPE_GAME_ROTATION_VECTOR);
}
if (orientationSensor == null) {
orientationSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR);
}
this.orientationSensor = orientationSensor;

scene = new SceneRenderer();
renderer = new Renderer(scene);
Expand Down

0 comments on commit 017923e

Please sign in to comment.