如何将视图放在Youtube Data API的youtubePlayer顶部

问题描述

我正在尝试在YouTube数据API的youtubePlayer上放置两个按钮,以在我的youtube播放器中获得前进和后退10秒的功能

<androidx.constraintlayout.widget.ConstraintLayout 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=".YoutubePlayer">

    <com.google.android.youtube.player.YouTubePlayerView
        android:id="@+id/youtube_player_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

    </com.google.android.youtube.player.YouTubePlayerView>

    <Button
        android:id="@+id/backwardButton"
        android:layout_width="150dp"
        android:layout_height="match_parent"
        android:alpha="0"
        android:onClick="backward"
        android:text="Button"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/forwardButton"
        android:layout_width="150dp"
        android:layout_height="match_parent"
        android:alpha="0"
        android:onClick="forward"
        android:text="Button"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent" />


</androidx.constraintlayout.widget.ConstraintLayout>

但是只要youtube播放器加载,它就会消除所有子项。

在youtube播放器后,我尝试将按钮添加到youtube播放器视图中,但失败了

youTubePlayerView.addView(backwardButton);
youTubePlayerView.addView(forwardButton);

但是我的应用程序为此而迷恋

然后我尝试通过以下方式使其在youtubePlayer加载后可见

backwardButton.setVisibility(View.VISIBLE);
forwardButton.setVisibility(View.VISIBLE);

但它仍然会粉碎

我使用无镶边播放器样式尝试了Stack Overflow上所有可用的解决方

youTubePlayer.setPlayerStyle(YouTubePlayer.PlayerStyle.chromeless);

但它仍然失败。

如何解决这个问题

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...