How I can hide controls, full screen buttons in Yo

2020-07-06 03:03发布

I am trying to hide the buttons in a Youtube video player (api). I used

player.setShowFullscreenButton(false)

this hides the fullscreen button successfully, but I did not find way to hide the control button -- that button can go to youtube application.

I tried using

player.setPlayerStyle(PlayerStyle.MINIMAL);

This hides all buttons, but also changes the progress bar, but I need the old progress bar.

Any help?

4条回答
唯我独甜
2楼-- · 2020-07-06 03:49

To disable only full screen

setShowFullscreenButton(boolean show)

Shows or hides the fullscreen button on the player controls.

For Reference See this link

查看更多
聊天终结者
3楼-- · 2020-07-06 03:51

You can initiate the player as a "Chromeless" player. That should do it.

查看更多
家丑人穷心不美
4楼-- · 2020-07-06 03:56

I only know this works with version 1.2.2 of Youtube player of the API. Hides YOUTUBE button only.

((ViewGroup)((ViewGroup)((ViewGroup)((ViewGroup)((ViewGroup)((ViewGroup)((ViewGroup)((ViewGroup)findViewById(R.id.YOUR_VIDEO_PLAYER_ID)).getChildAt(0)).getChildAt(0))
                .getChildAt(4)).getChildAt(0)).getChildAt(0)).getChildAt(3)).getChildAt(0)).getChildAt(1).setVisibility(View.GONE);
查看更多
姐就是有狂的资本
5楼-- · 2020-07-06 03:58

Try this

In your onInitializationSuccess method use this code

player.setPlayerStyle(YouTubePlayer.PlayerStyle.CHROMELESS);

Full code

@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider,
                                    YouTubePlayer player, boolean wasRestored) {
    if (!wasRestored) {

        // loadVideo() will auto play video
        // Use cueVideo() method, if you don't want to play it automatically
        player.loadVideo(Config.YOUTUBE_VIDEO_CODE);

        // Hiding player controls
        player.setPlayerStyle(YouTubePlayer.PlayerStyle.CHROMELESS);
      //player.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT);
    }
}

Note:-

1. For showing all interactive controls

public static final YouTubePlayer.PlayerStyle DEFAULT

2.For hiding all interactive controls

public static final YouTubePlayer.PlayerStyle CHROMELESS

3.For showing only a time bar and play/pause controls

public static final YouTubePlayer.PlayerStyle MINIMAL

For more visit official link

查看更多
登录 后发表回答