英文:
How to mute embed youtube video in youtubeplayerview
问题
以下是您提供的代码的中文翻译部分:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
myouTubePlayerView = findViewById(R.id.utube_video);
myurl = "haE1BA1joxg";
monInitializedListener = new YouTubePlayer.OnInitializedListener() {
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
youTubePlayer.loadVideo(myurl);
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
}
};
myouTubePlayerView.initialize(YoutubeConfig.getApiKey(), monInitializedListener);
}
英文:
I am using Youtube Api for playing videos in my app, video is playing fine but i want to mute the video programmatically. I searched a lot about it but i am not finding anything for disable the sound of video.
Please help me and tell me the solution to mute the YouTube video.
This is my code:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
myouTubePlayerView = findViewById(R.id.utube_video);
myurl = "haE1BA1joxg";
monInitializedListener = new YouTubePlayer.OnInitializedListener() {
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
youTubePlayer.loadVideo(myurl);
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
}
};
myouTubePlayerView.initialize(YoutubeConfig.getApiKey(), monInitializedListener);
}
答案1
得分: 1
你正在寻找YouTube播放器API,在该文档中你可以找到这个内容:
https://developers.google.com/youtube/iframe_api_reference#Playback_controls
player.mute():Void
这是用于静音视频的API调用。
英文:
You are looking for YouTube Player API, under that documentation you can find this:
https://developers.google.com/youtube/iframe_api_reference#Playback_controls
player.mute():Void
Is the API call for muting the video.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论