-
-
Notifications
You must be signed in to change notification settings - Fork 788
PlayerUIController
The PlayerUIController is responsible for controlling the UI of the player. You can see its contract here.
You can get a reference to the PlayerUIController from the YouTubePlayerView by calling this method
PlayerUIController YouTubePlayerView.getPlayerUIController();
PlayerUIController exposes a method called setVideoTitle(String videoTitle).
If you want to use this method you need to find the title of the video somewhere. The recommended approach is to use the YouTube Data API to fetch the video title from the video id. You can see an example in the method setVideoTitle(PlayerUIController playerUIController, String videoId) from the sample app.
If you want to play live videos you must setup the UI accordingly by calling this method
PlayerUIController.enableLiveVideoUI(boolean);
Unfortunately there is no way for the player to recognize if it is playing a live video or not, therefore is up to the developer to change the UI accordingly.
If you want you can set custom actions on the right and left side of the Play/Pause button of the player
PlayerUIController.setCustomAction1(Drawable icon, OnClickListener listener );
PlayerUIController.setCustomAction2(Drawable icon, OnClickListener listener );
PlayerUIController.showCustomAction1(boolean show);
PlayerUIController.showCustomAction2(boolean show);
by default if you set a custom action with a null listener the icon won't be visible.
You can also change the behavior of the full screen button, in case your app requires custom logic to enter full screen
PlayerUIController.setCustomFullScreenButtonListener(OnClickListener);
Another way to add custom actions to the UI is with the methods addView(View view) and removeView(View view). The provided View will be added to the top of the player (where the eventual menu and video title are).