首页 > 解决方案 > 如何在exoplayer android中检测视频是纵向(垂直)还是横向(水平)拍摄

问题描述

我正在使用 exoplayer 播放我的视频。一切正常。我不想拉伸我的视频,如果它是横向模式,我可以使用它来实现它,AspectRatioFrameLayout,现在使用 AspectRatioFrameLayout,使我的横向视频完美,但在 potrait 模式下,它会在左侧和右侧留下黑色空间。下面是示例

肖像模式

在此处输入图像描述

横向模式这很好

在此处输入图像描述

<com.google.android.exoplayer2.ui.AspectRatioFrameLayout
    android:id="@+id/videoFrame"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center">

    <com.google.android.exoplayer2.ui.PlayerView
        android:id="@+id/player_view_story"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/transparent"
        app:use_controller="false" />
</com.google.android.exoplayer2.ui.AspectRatioFrameLayout>

当我尝试使用下面的代码时,我的肖像模式是完美的,但风景会被拉伸。需要知道是否有一种方法可以同时进行。

player_view_story.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_ZOOM

标签: androidexoplayerexoplayer2.x

解决方案


推荐阅读