Reputation: 944
I added exoplayer to my app.
I fixed the screen orientation to portrait for whole my app.
I need exoplayer to be rotated to landscape mode.
How can I handle this issue?
I just need to rotate the exo frame and not the whole fragment or activity.
Upvotes: 4
Views: 8989
Reputation: 4808
This can be done by simple two lines of code,
When you click any button and want to rotate to LANDSCAPE
((Activity) mContext).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
And when wanna rotate back to PORTRAIT
((Activity) mContext).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
Upvotes: 0
Reputation: 45070
You dont need extra library to do so, simply set app:surface_type="texture_view"
and then you can rotate texture_view
in xml using android:rotation="39"
or in code using mainVideoView.rotation = 39f
:
<com.google.android.exoplayer2.ui.SimpleExoPlayerView
android:id="@+id/mainVideoView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:focusable="true"
android:nextFocusLeft="@id/resizeLeft"
android:nextFocusRight="@id/resizeRight"
android:nextFocusUp="@+id/mediaContainer"
android:nextFocusDown="@+id/exo_pause"
app:surface_type="texture_view"
android:rotation="39"
app:controller_layout_id="@layout/custom_playback_control" />
Upvotes: -1
Reputation: 9597
You can use https://github.com/rongi/rotate-layout to draw ExoPlayer contents rotated, but for that lib to work you will have to use app:surface_type="texture_view"
in your PlayerView
Upvotes: 6