Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 251
user2855698 Avatar asked Oct 07 '13 17:10

user2855698


People also ask

How do I take control off my YouTube screen?

Disable Accessibility Player for YouTube (Android Only)Open the YouTube's Accessibility menu (YouTube > Settings > Accessibility), toggle on Accessibility player, and tap Hide player controls.

What is a YouTube player?

A YouTubePlayer provides methods for loading, playing and controlling YouTube video playback. Get an instance of this class by calling initialize on a YouTubePlayer.


2 Answers

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

like image 58
Ibrahim Ulukaya Avatar answered Oct 21 '22 15:10

Ibrahim Ulukaya


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

like image 20
Sunil Avatar answered Oct 21 '22 15:10

Sunil