I am working on audio conference project to work on all the latest browsers. Who ever talks on the mic, will generate a event at the server and calls a function(whoIsTalking()) in javascripts. I am replacing the CSS to animate such that the volume raises by switching the css(in turn switches the background pics) as needed. But the javascript runs so fast that i don't see any change in css. I need the volume raise and lows when the speaker is speaking. Can anyone help me on this?
this.whoIsTalking = function (action, id, type) {
if(_selfM.logging) {
log.info("The current user who is " + action + " with id " + id + " , recieved from :" + type);
}
talker(id);
}
/**
* Change class for talker
*
*/
function talker(id) {
if(_selfM.logging) log.debug('Now in the "talker" function');
var talker = "talker_" + id;
$('span#' + talker).alterClass('btn-volum*', 'btn-volume_low');
console.log($('span#' + talker));
$('span#' + talker).alterClass('btn-volum*', 'btn-volume_medium');
$('span#' + talker).alterClass('btn-volum*', 'btn-volume_high');
$('span#' + talker).alterClass('btn-volum*', 'btn-volume_medium');
$('span#' + talker).alterClass('btn-volum*', 'btn-volume_low');
$('span#' + talker).alterClass('btn-volum*', 'btn-volume');
}
Note: alterClass('x','y') is same as removeClass('x').addClass('y'); ref : alterClass
$('span#' + talker).alterClass(x, y).delay(100).alterClass(x, y)......delay()only works with methods that use the animation queue so it probably doesn't work with.alterClass().