我正在尝试隐藏YouTube视频播放器(api)中的按钮。 我使用了
player.setShowFullscreenButton(false)
这样做可以成功隐藏全屏按钮,但我没有找到方法来隐藏控制按钮--那个按钮可以跳转到YouTube应用程序。
我尝试使用
player.setPlayerStyle(PlayerStyle.MINIMAL);
这会隐藏所有按钮,但也会更改进度条,但我需要旧的进度条。
有什么帮助吗?
我正在尝试隐藏YouTube视频播放器(api)中的按钮。 我使用了
player.setShowFullscreenButton(false)
这样做可以成功隐藏全屏按钮,但我没有找到方法来隐藏控制按钮--那个按钮可以跳转到YouTube应用程序。
我尝试使用
player.setPlayerStyle(PlayerStyle.MINIMAL);
这会隐藏所有按钮,但也会更改进度条,但我需要旧的进度条。
有什么帮助吗?
在你的onInitializationSuccess方法中使用以下代码
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);
}
}
注意:
1. 显示所有交互控件
public static final YouTubePlayer.PlayerStyle DEFAULT
2. 隐藏所有交互控件
public static final YouTubePlayer.PlayerStyle CHROMELESS
3. 仅显示时间轴和播放/暂停控件
public static final YouTubePlayer.PlayerStyle MINIMAL
更多信息请访问官方链接
我只知道这适用于API的Youtube播放器版本1.2.2。仅隐藏YOUTUBE按钮。
((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);
ClassCastException: ProgressBar cannot be cast to android.view.ViewGroup
- Hamzeh Soboh