Skip to content
This repository has been archived by the owner on Nov 20, 2021. It is now read-only.

Muting video #41

Closed
arunshan opened this issue May 16, 2016 · 1 comment
Closed

Muting video #41

arunshan opened this issue May 16, 2016 · 1 comment

Comments

@arunshan
Copy link

arunshan commented May 16, 2016

Hi @bfred-it
Setting muted=true does not work on the iPhone.
Also unable to adjust volume on the video. Is this a limitation?

FYI, there is an audio track in the video.

@fregante
Copy link
Owner

fregante commented May 17, 2016

It's a limitation of iOS in general, you cannot control the volume of <audio> nor <video>

It's probably possible to change the volume of an audio element through the Web Audio API but I was not able to successfully combine these two:

http://webaudioapi.com/samples/audio-tag/
http://webaudioapi.com/samples/volume/

If someone were able to do it, it would definitely be wrapped into a more generic audio-volume-polyfill that could be used anywhere.

So far my code was:

// create the audio context
var context = new (window.AudioContext || window.webkitAudioContext)();

// create the audio element
var audio = document.createElement( 'audio' );
audio.src = 'https://rawgit.com/bower-media-samples/big-buck-bunny-480p-30s/master/video.mp4';
audio.crossOrigin = 'anonymous'

// create the volume changer
var gainNode = context.createGain();
gainNode.gain.value = 0.1; // set the volume

// connect the audio element and the volume to the context
var audioSource = context.createMediaElementSource( audio );
audioSource.connect( context.destination );
gainNode.connect( context.destination );

// play the audio element on user interaction
document.body.ontouchstart = audio.play.bind( audio )

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants