16

I have tried:

videojs("cats").ready(function(){
myPlayer.volume(0);
});

... but it did not work. I searched here and through the documents and am not finding the answer, or using the code correctly.

Matt Ball
  • 354,903
  • 100
  • 647
  • 710
Will X
  • 327
  • 1
  • 2
  • 7
  • Do you want muted (0% volume) or quiet (50%) volume? The title does not ask the same question as the code. – Matt Ball Jul 11 '13 at 04:44
  • Sorry, I was up a little too late. :) Yes, even at 0 or 0.0 it is still at full volume. Is there a full example of this somewhere? – Will X Jul 11 '13 at 15:29
  • How about [providing a complete example that demonstrates how you're actually using this snippet?](http://sscce.org) http://jsfiddle.net is a nice tool for this. – Matt Ball Jul 11 '13 at 15:31

7 Answers7

18

might be a bit late.

In your javascript, try:

myPlayer.muted(true);
dannio
  • 900
  • 8
  • 12
15

Okay so the answer is easy:

just add: muted to the tag, such as:

 <video id="cats" class="video-js vjs-fullscreen vjs-default-skin" muted autoplay controls loop preload="auto" width="600" height="400"
      data-setup="{}">
    <source src="x.webm" type='video/webm' /> 
  </video>
Will X
  • 327
  • 1
  • 2
  • 7
6

When you init the player, you can set muted to true.

videojs("cats", { muted: true });
heff
  • 3,171
  • 1
  • 20
  • 21
4

There'r few ways to set Mute on VideoJS.

 {muted: true} OR this.volume(0) OR "muted" attribute in a video tag

Sample below:

  var setupOpt = {
      'techOrder': ["html5", "flash"],
      'muted'    : true, //OR YOU CAN ADD MUTE Attr.
      'controls' : true,
      'autoplay' : true,
      'preload'  : 'auto',
      'height'   : '500px',
      'width'    : '500px',
      'poster'   : "Url for poster"
  };

  videojs("my-video", setupOpt , function() {
    var player = this;
        player.src({ src: "URL!", type: 'TYPE!'});
        player.volume(0); //Volume range 0.0 to 1 (0.0, 0.1, 0.2 ...)
    // });
  });
7urkm3n
  • 6,054
  • 4
  • 29
  • 46
0

Your code myPlayer.volume(0.5); will not mute the video. You need to change that to:

myPlayer.volume(0);

From the documentation: "0 is off (muted), 1.0 is all the way up, 0.5 is half way."

Austin Henley
  • 4,625
  • 13
  • 45
  • 80
  • 2
    Yes, even at 0 or 0.0 it is still at full volume. Is there a full example of this somewhere? I have searched all over but cannot find it. I am sure this is simple but I cannot get it to initiate. Thank you. – Will X Jul 11 '13 at 14:24
  • I'm still searching this myself – sojim Jun 03 '15 at 07:45
0

Might be a bit late, but I think the solution is quite easy. Change your code from myPlayer to this. Should look like this:

videojs("cats").ready(function(){
    this.volume(0);
});

This is untested, but it should work, I think. Even if you had a variable myPlayer that takes the player, it will contain it only after having set the .ready() callback, so in the callback, the variable won't be holding your player.

Maybe my explanation is wrong, but you could try this... ;-)

EDIT: Just saw some of the other answers, that should also work.

mvmoay
  • 1,535
  • 3
  • 15
  • 26
0

The problem in the code is that the myPlayer variable is not defined

videojs("cats", {}, function(){
          var myPlayer = this;
          myPlayer.volume(0);
});
Vicent Ibáñez
  • 439
  • 1
  • 6
  • 10