gpt4 book ai didi

android - 如何在android中禁用youtube Player View的控件?

转载 作者:行者123 更新时间:2023-11-30 02:14:20 25 4
gpt4 key购买 nike

我做了一个 youtube api 演示,我的要求是我想从 YoutubePlayerView(seekbar) 禁用 userControlls,我搜索并找到了解决方案,但我不知道如何在我的代码中应用它。可以有人建议我如何在 android 中禁用 youtube Player View 的搜索栏吗?

我的代码如下:

代码

public class VideoActivity extends YouTubeBaseActivity implements
OnClickListener, YouTubePlayer.OnInitializedListener {
Button btn_toprated;
TextView tv_site;
TextView tv_guide;
public static final String API_KEY = "AIzaSyBV-3VbYw-ljgkj9tDg5pOVEAE8hNmG6q8";
public static final String VIDEO_ID = "1QydBspryNE";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.video_activity);
super.onCreate(savedInstanceState);
init();
PlayerStyle style = PlayerStyle.CHROMELESS;

}

void init() {

btn_toprated = (Button) findViewById(R.id.btn_toprated);
tv_guide = (TextView) findViewById(R.id.tv_guide);
tv_site = (TextView) findViewById(R.id.tv_site);
btn_toprated.setOnClickListener(this);
tv_guide.setOnClickListener(this);
tv_site.setOnClickListener(this);

YouTubePlayerView youTubePlayerView = (YouTubePlayerView) findViewById(R.id.youtubeplayerview);

youTubePlayerView.initialize(API_KEY, this);
}

@Override
public void onClick(View v) {
Intent i;
switch (v.getId()) {

case R.id.tv_guide:
i = new Intent(VideoActivity.this, GuideActivity.class);
startActivity(i);
break;
case R.id.tv_site:
String url = "http://www.system500.com";
i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
break;
case R.id.btn_toprated:
i = new Intent(VideoActivity.this, TopRatedActivity.class);
startActivity(i);
break;
}
}

@Override
public void onBackPressed() {
// TODO Auto-generated method stub

}

@Override
public void onInitializationFailure(Provider provider,
YouTubeInitializationResult result) {
Toast.makeText(getApplicationContext(), "onInitializationFailure()",
Toast.LENGTH_LONG).show();
}

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

}
}

}

最佳答案

您可以使用 YouTubePlayer.PlayerStyle枚举类,要么以这种方式

player.setPlayerStyle(YouTubePlayer.PlayerStyle.CHROMELESS);

player.setPlayerStyle(YouTubePlayer.PlayerStyle.MINIMAL);

关于android - 如何在android中禁用youtube Player View的控件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29598465/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com