I have html5 webpage, with a slider and an audio track. I do not reffer to the sound tag property controls = "controls" (). I want my slider to control the volume from the audio file. If I use in my body tags , the following code it`s working perfectly. If I use in my body tags , the result is a deafening noise . This is my code:
HTML
<!doctype html>
<html lang="en">
<head>
<title>Rain</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="css/ui-lightness/jquery-ui-1.8.23.custom.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body onLoad="run();">
<div id="slider"></div>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery-ui.js"></script>
<script type="text/javascript" src="js/ui.js"></script>
</body>
</html>
JS
// Invoke new Audio object
var ad = new Audio('rainloop.mp3');
//default play audio
ad.play();
//volume slider
$('#slider').slider({
min:0,
max:100,
step:1,
value:50,
slide: function(){
ad.volume = parseFloat(this.value / 10);
}
} );
I think the problem its here : ad.volume = parseFloat(this.value / 10);
I
ve tried also : ad.volume = parseFloat(this.value) and ad.volume = parseFloat(this.value / 100) and it`s still making a incomprehensible noise.