Reputation: 311
volume off does not work in html5 video ipad 2.
player = document.getElementById(element_id);
if (player.muted){
player.muted = false;
player.volume = 1;
//player.volume(1);
}else{
player.muted = true;
player.volume = 0;
//player.volume(0);
}
Upvotes: 5
Views: 7486
Reputation: 211
I've been able to achieve something like this by doing the following:
To mute, remove the entire element. Easily done if you're using jquery.
$('#audio-elem').remove();
To unmute, simply add it back in!
$('body').append('');
I did find two issues with this method though:
Hope it helps!
Upvotes: -2
Reputation: 7853
I'm afraid iOS does not allow changing the volume with Javascript. From Apple's documentation (emphasis is mine):
On the desktop, you can set and read the volume property of an or element. This allows you to set the element’s audio volume relative to the computer’s current volume setting. A value of 1 plays sound at the normal level. A value of 0 silences the audio. Values between 0 and 1 attenuate the audio.
This volume adjustment can be useful, because it allows the user to mute a game, for example, while still listening to music on the computer.
On iOS devices, the audio level is always under the user’s physical control. The volume property is not settable in JavaScript. Reading the volume property always returns 1.
There is no mention of the muted
property, but experimenting shows that it can't be changed either:
http://jsbin.com/anikab/1/
Upvotes: 13