如何在YouTubePlayerView中静音嵌入的YouTube视频。

huangapple go评论64阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2020年9月7日 14:37:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/63772482.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定