How I can hide controls, full screen buttons in Youtube Player android API?
Asked Answered
D

4

10

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?

Decigram answered 7/10, 2013 at 17:55 Comment(0)
M
7

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

Myogenic answered 8/10, 2013 at 18:5 Comment(1)
But I want all the controls of YouTubePlayer.PlayerStyle.DEFAULT Except "YouTube" Button. How to do this in Android. It's doable in iOS & Javascript.Lakshmi
B
1

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

Byroad answered 14/11, 2017 at 8:31 Comment(0)
E
0

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);
Eatable answered 18/1, 2017 at 17:7 Comment(1)
ClassCastException: ProgressBar cannot be cast to android.view.ViewGroupProspectus
D
0

To disable only full screen

setShowFullscreenButton(boolean show)

Shows or hides the fullscreen button on the player controls.

For Reference See this link

Dreamadreamer answered 14/12, 2017 at 11:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.