HTML and CSS Reference
In-Depth Information
var length = (length * 1000),
currentTime = 0,
interval,
_self = this,
state = this.state.STOPPED,
updateInterval = 1000 / 30;
var setCurrentTime = function(time){
currentTime = time;
_self.callbacks.didUpdateTime.call(_self, currentTime);
};
var updateTime = function(){
if(currentTime < length){
setCurrentTime(currentTime + updateInterval);
} else {
_self.stop();
}
};
this.getCurrentTime = function(){
return currentTime;
};
this.getLength = function(){
return length;
};
this.getState = function(){
return state;
};
this.stop = function(){
window.clearInterval(interval);
state = _self.state.STOPPED;
_self.setCurrentTime(0);
_self.callbacks.didStop.call(_self);
};
this.play = function(){
if(state != _self.state.PLAYING){
interval = window.setInterval(updateTime, updateInterval);
state = _self.state.PLAYING;
_self.callbacks.didStartPlaying.call(_self);
}
};
Search WWH ::




Custom Search