On my site, I have an iframe element that is playing music (I cannot use a audio element in this instance) and I would like to be able to change the volume using a slider.
I have tried the following:
HTML:
<iframe src="bg.mp3" allow="autoplay" style="display:none" id="iframeAudio"></iframe>
<input id="vol-control" type="range" min="0" max="100" step="1" oninput="SetVolume(this.value)" onchange="SetVolume(this.value)" />
Javascript:
var iframe = document.getElementById('iframeAudio');
iframe.setVolume(val / 100);
However, I get the following error in the console:
Uncaught TypeError: iframe.setVolume is not a function
How can I do this?