当景观模式播放肖像视频时,接下来的按钮和以前的按钮被隐藏

发布于 2025-01-31 13:31:24 字数 2614 浏览 4 评论 0原文

我的应用程序的一部分显示了手机中的视频并提供视频播放功能。这是系层布局实现。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".view.activity.ExoplayerActivity"
android:gravity="center"
android:background="@android:color/black">

<com.google.android.exoplayer2.ui.PlayerView
    android:id="@+id/videoFullScreenPlayer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:rewind_increment="10000"
    app:fastforward_increment="10000"
    app:use_sensor_rotation="true"
    android:focusable="true"
    app:auto_show="true"
    app:use_controller="true"
    app:resize_mode="fill">
<FrameLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:id="@+id/video_FL"
        android:background="@color/transparent">
        <ImageView
            android:layout_width="23dp"
            android:layout_height="23dp"
            android:id="@+id/backBtn_IV"
            android:src="@drawable/ic_back_longtail"
            android:tint="@color/white"
            android:layout_marginLeft="10dp"
            android:layout_gravity="start|center_vertical"/>
</FrameLayout>
    </com.google.android.exoplayer2.ui.PlayerView>

</RelativeLayout>

一切正常,除了自动座架打开并且在肖像模式下拍摄的视频时,在景观模式下,未显示下一个和以前的按钮。

这样:

“丢失了下一个和上一个按钮”

在肖像模式下,我们可以看到所有用户控制器按钮,例如:

“在此处输入图像描述”

我知道没有空间容纳所有按钮,所以我想在整个屏幕上扩展控件。但是我无法做到。

我尝试实现自定义播放器,例如 this 。我试图像这样在屏幕上拉伸控件:

    DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    int screenWidth = displayMetrics.widthPixels;
    LinearLayout controls = findViewById(R.id.controls);
    ViewGroup.LayoutParams controlLayout = controls.getLayoutParams();
    controlLayout.width = screenWidth;
    controls.setLayoutParams(controlLayout);

它根本不会显示任何控制按钮。

有什么想法如何使用户控制器在屏幕上伸展并显示肖像视频以景观模式播放的控制器的所有按钮?提前致谢。

A part of my app shows the videos in the phone and provides video playing functionality. This is the exoplayer layout implementation.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".view.activity.ExoplayerActivity"
android:gravity="center"
android:background="@android:color/black">

<com.google.android.exoplayer2.ui.PlayerView
    android:id="@+id/videoFullScreenPlayer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:rewind_increment="10000"
    app:fastforward_increment="10000"
    app:use_sensor_rotation="true"
    android:focusable="true"
    app:auto_show="true"
    app:use_controller="true"
    app:resize_mode="fill">
<FrameLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:id="@+id/video_FL"
        android:background="@color/transparent">
        <ImageView
            android:layout_width="23dp"
            android:layout_height="23dp"
            android:id="@+id/backBtn_IV"
            android:src="@drawable/ic_back_longtail"
            android:tint="@color/white"
            android:layout_marginLeft="10dp"
            android:layout_gravity="start|center_vertical"/>
</FrameLayout>
    </com.google.android.exoplayer2.ui.PlayerView>

</RelativeLayout>

Everything works fine, except that when autorotate is on and a video which is taken in portrait mode is played in landscape mode, the NEXT and PREVIOUS buttons are not shown.

Like this:

Missing NEXT and PREVIOUS buttons

On portrait mode, we can see all the user controller buttons, like this:

enter image description here

I understand there isn't space to accommodate all the buttons, so I wanted to stretch the controls across the entire screen. But I am not able to do it.

I tried implementing custom Player like this. And I tried to stretch the controls across the screen like this:

    DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    int screenWidth = displayMetrics.widthPixels;
    LinearLayout controls = findViewById(R.id.controls);
    ViewGroup.LayoutParams controlLayout = controls.getLayoutParams();
    controlLayout.width = screenWidth;
    controls.setLayoutParams(controlLayout);

It would not show any of the control buttons at all.

Any idea how to get the user controller to stretch across the screen and show all the buttons of the controller when a portrait video is played in landscape mode? Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文