YouTube的退出全屏模式TextView的能见度问题 [英] Youtube Exit Full Screen Mode TextView Visibility Issue

查看:752
本文介绍了YouTube的退出全屏模式TextView的能见度问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我播放视频在全屏模式下,当我做后退按钮,我能够退出全屏模式点击 - 但无法显示TextView的,我有隐藏在全屏的情况下

I am playing video in a full screen mode, and when I do click on back button I am able to exit full screen mode - but not able to show TextView which I have hide in case of full screen.

要隐藏的TextView在全屏模式下,我使用低于code:

To Hide textView on Full Screen mode, I am using below code:

@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider,
        YouTubePlayer player, boolean wasRestored) {
    if (!wasRestored) {
        showPlayer();
        videoPlayer = player;
        videoPlayer.setOnFullscreenListener(new OnFullscreenListener() {

            @Override
            public void onFullscreen(boolean _isFullScreen) {
                fullScreen = _isFullScreen;
                textView.setVisibility(View.GONE); // hiding
            }
        });
        videoPlayer.loadVideo(actualVideo.getVideoId());
    }
}

要显示的TextView,当我使用退出全屏模式:

To show textView, when I Exit Full Screen mode using:

@Override
public void onBackPressed() {
    if (fullScreen){
        videoPlayer.setFullscreen(false);
        textView.setVisibility(View.VISIBLE); // showing

    } else{
        super.onBackPressed();
    }
}

我不知道为什么?但我没有得到我的TextView在可视状态,当我做水龙头上的后退按钮(我的意思是退出全屏模式)。

I don't know why? But I am not getting my textView as in visible state, when I do tap on back button (I mean exit full screen mode).

推荐答案

_isFullScreen在公共无效onFullscreen(布尔_isFullScreen)是全屏状态,如果这是真的就意味着玩家去到全屏模式,如果是假的就意味着玩家切换全屏模式回来,当你去到全屏模式,并分别与真假值来自全屏模式切换回该监听器被调用两次。您应修改code如下

_isFullScreen inside public void onFullscreen(boolean _isFullScreen) is state of full screen, if it's true it means player is gone to full screen mode and if it is false it means the player is switched back from full screen mode and this listener is called both times when you go to full screen mode and come back from full screen mode with true and false value respectively. You should modify code as below

videoPlayer.setOnFullscreenListener(new OnFullscreenListener() {

        @Override
        public void onFullscreen(boolean _isFullScreen) {
            fullScreen = _isFullScreen;
            if(_isFullScreen){
            textView.setVisibility(View.GONE); // hide text as player switched to full screen mode
            } else {
            textView.setVisibility(View.VISIBLE); // show text as player switched back from full screen mode, changing visibility here instead of onBackPressed have advantage that even if user switches back from full screen mode using control button on player instead of press back button the text will still come to visible
            }
        }
    });

而你onBack pressed监听器将只用于从全屏模式切换回来的球员,如果球员是在全屏模式下的时候后退按钮是pressed;

while your onBackPressed listener will be just used for switching player back from full screen mode if player was in full screen mode when back button was pressed;

@Override
public void onBackPressed() {
if (fullScreen){
    videoPlayer.setFullscreen(false);

} else{
    super.onBackPressed();
}
}

这篇关于YouTube的退出全屏模式TextView的能见度问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆