Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
视频暂停时如何在android中隐藏视频播放器?_Android_Video_Youtube Api_Android Videoview - Fatal编程技术网

视频暂停时如何在android中隐藏视频播放器?

视频暂停时如何在android中隐藏视频播放器?,android,video,youtube-api,android-videoview,Android,Video,Youtube Api,Android Videoview,我有一个视频播放器和youtube播放器的布局,第一个是电影,第二个是预告片,我想在相同的位置显示它们(视频容器) 如果我不开始看电影,我有一张电影海报->我看youtube预告片->回到电影海报,然后一切正常 如果我开始看电影->暂停电影->观看预告片,那么视频播放器中的片段就会出现在youtube播放器前面 当应用程序处于纵向视图时,youtube播放器位于视频播放器后面,我只能听到声音,而处于横向视图时,则静止的youtube播放器位于暂停的视频帧后面(见图)。如何隐藏视频播放器 xml

我有一个视频播放器和youtube播放器的布局,第一个是电影,第二个是预告片,我想在相同的位置显示它们(视频容器)

如果我不开始看电影,我有一张电影海报->我看youtube预告片->回到电影海报,然后一切正常

如果我开始看电影->暂停电影->观看预告片,那么视频播放器中的片段就会出现在youtube播放器前面

当应用程序处于纵向视图时,youtube播放器位于视频播放器后面,我只能听到声音,而处于横向视图时,则静止的youtube播放器位于暂停的视频帧后面(见图)。如何隐藏视频播放器

xml


您是否有解决相同问题的方法。
trailerButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            videoPlayerContainer.setVisibility(View.GONE);
            youtubePlayerContainer.setVisibility(View.VISIBLE);
            if (videoPlayerView.isPlaying()) {
                videoPlayerView.pause();
                videoPlayerView.setVisibility(View.GONE);
            }
            youTubePlayerFragment.initialize(YOUTUBE_API_KEY, onInitializedListener);
        }
    });
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">

    <RelativeLayout
        android:id="@+id/movie_player_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:clickable="true"
        android:visibility="visible">

        <ImageView android:id="@+id/movie_player_image"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_centerInParent="true"
            android:scaleType="fitCenter" />

        <app.view.VideoPlayer
            android:id="@+id/movie_player"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@android:color/black"
            android:visibility="gone"
            android:layout_centerInParent="true" />

    </RelativeLayout>

    <FrameLayout android:id="@+id/youtube_player_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:visibility="gone">

        <fragment android:id="@+id/youtube_fragment"
            android:name="app.fragment.YouTubeFragment"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </FrameLayout>

</RelativeLayout>