旋转 Exoplayer

4
我在我的应用中添加了ExoPlayer。
我将整个应用程序的屏幕方向固定为纵向。
我需要将 ExoPlayer 旋转到横向模式。
我该如何解决这个问题?
我只需要旋转 Exo 框架而不是整个片段或活动。

你可以尝试使用ExoPlayerRotation in ReactExoPlayerView - L.Petrosyan
你可以尝试这个ExoPlayer在ReactExoPlayerView中的旋转 - L.Petrosyan
4个回答

6

旋转不需要第三方库。您可以将 android:rotation="90" 设置到您的布局中,或者在 Kotlin 中调用 playerView.rotation = 90f。设置 app:surface_type="texture_view" 对于旋转是必须的。 - Albert Vila Calvo
2
这是最好的答案,浪费了3天时间,最终这个解决方案特别适用于playerview和exoplayer。 - 1234567
点赞,只有这个解决方案可以在Android TV上运行。 - Tam Huynh

1
exoPlayerView.getVideoSurfaceView().setRotation(90);

1
请不要仅仅发布代码作为答案,还要提供解释您的代码是如何解决问题的。带有解释的答案通常更有帮助和更高质量,并且更有可能吸引赞同。 - Mark Rotteveel
它不能与SurfaceView一起使用。 - VinceStyling

1
这可以通过简单的两行代码实现,
当您点击任何按钮并想要旋转到LANDSCAPE模式时。
((Activity) mContext).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);

当想要旋转回纵向时

((Activity) mContext).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);

-2

您不需要额外的库来实现这一点,只需设置 app:surface_type="texture_view",然后您就可以在xml中使用 android:rotation="39" 或者在代码中使用 mainVideoView.rotation = 39f 来旋转 texture_view

  <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" />

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接