If you are talking about using pure JavaScript to control audio level, I doublt it can because the language is not a audio player...
Taywin
Posting Maven
2,633 posts since Apr 2010
Reputation Points: 275
Solved Threads: 375
Skill Endorsements: 17
If you could obtain the value, then you may need a local variable and store the current captured value. Whenever the value is changed, compared the new value with the current value and deal with it. Then, update the current value to the changed value. If you still do not understand, please provide the script where you obtain the value and where the value changing event occur.
Taywin
Posting Maven
2,633 posts since Apr 2010
Reputation Points: 275
Solved Threads: 375
Skill Endorsements: 17
It's going to be inside }} at line 41. Also, you need to have a currentVolume declared somewhere outside to be used as global for the function. A question I would ask is that can you specify the value of increase/decrease volume? If so, assume the value range from 0 as 0% and 50 as 100% of volume. The percentage of the volume would be computed as VOLUMN_PERCENTAGE = curX*2;. In order to do so, you need to update certain things...
var currentVolume = 50; // default is max?
...
curX= canvas.mouse.x;
if(curX<0)
{
this.moveTo(0,10);
curX = 0;
}//lower bound
else if(curX>50)
{
this.moveTo(50,10);
curX = 50;
}//upper bound
else
{
this.moveTo(canvas.mouse.x,10);
}
// if there is no way to set a step value, then below is what it is...
if (curX>currentVolume) { increaseVolume(); }
else if (curX<currentVolume) { decreaseVolume(); }
// otherwise, you could compute the value...
// my assumption is that there is a setVolume(VALUE) function
// setVolume(curX*2);
currentVolume = curX;
},
Taywin
Posting Maven
2,633 posts since Apr 2010
Reputation Points: 275
Solved Threads: 375
Skill Endorsements: 17
It means that if you don't use the if-else statement, you could simply use setVolume() to the value the curX is selected instead. However, the currentVolume must still be set to curX after the move() function is called.
Taywin
Posting Maven
2,633 posts since Apr 2010
Reputation Points: 275
Solved Threads: 375
Skill Endorsements: 17