0

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 Answers1

1

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.

saykin
  • 21
  • 5