hi this is the code I'm using to play a shoutcast cast stream works fine but not able to change the volume is this wrong I'm new at this.
<script>
function audioobject()
{
var link = new Audio('http://107.155.72.250:8000/;.mp3');
return link;
}
function startradio()
{
audioobject().play();
}
function changevolume(amount)
{
audioobject().setVolume(amount);
}
</script>
<input type="button" id="play" value="Play" onclick="startradio()"/>
<input type="range" id="vol" max="1" min="0" step="0.01" onchange="changevolume(this.value)"/>
hi this is the code I'm using to play a shoutcast cast stream works fine but not able to change the volume is this wrong I'm new at this.
<script>
function audioobject()
{
var link = new Audio('http://107.155.72.250:8000/;.mp3');
return link;
}
function startradio()
{
audioobject().play();
}
function changevolume(amount)
{
audioobject().setVolume(amount);
}
</script>
<input type="button" id="play" value="Play" onclick="startradio()"/>
<input type="range" id="vol" max="1" min="0" step="0.01" onchange="changevolume(this.value)"/>
Share
Improve this question
edited Jan 12, 2021 at 12:34
Brian Tompsett - 汤莱恩
5,89372 gold badges61 silver badges133 bronze badges
asked Apr 16, 2014 at 0:24
manitejamaniteja
7172 gold badges16 silver badges32 bronze badges
1 Answer
Reset to default 5The correct method to set the volume is audioobject.volume = VALUE
Here's a demo showing a similar setup as you want.
function changevolume(amount) {
var audioobject = document.getElementsByTagName("audio")[0];
audioobject.volume = amount;
}
<audio autoplay loop src="https://archive/download/animalsounds1/12wolveshowlfar.mp3"></audio>
<input type="range" id="vol" max="1" min="0" step="0.01" onchange="changevolume(this.value)" />