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.
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.
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>
When you init the player, you can set muted to true.
videojs("cats", { muted: true });
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 ...)
// });
});
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."
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.
The problem in the code is that the myPlayer variable is not defined
videojs("cats", {}, function(){
var myPlayer = this;
myPlayer.volume(0);
});