HTML and CSS Reference
In-Depth Information
this.getState = function(){
return state;
};
}
The getters in this example will simply return the private variable; however, you
may define a getter, such as getCurrentTimeInSeconds , that will modify the
return value so that the function returns the playback time in seconds. For
example:
this.getCurrentTimeInSeconds = function(){
return (currentTime / 1000);
}
Next, you must define the controls for the track, such as play, pause, and stop.
app.track = function(length){
...
this.stop = function(){
window.clearInterval(interval);
state = _self.state.STOPPED;
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);
}
};
this.pause = function(){
window.clearInterval(interval);
state = _self.state.PAUSED;
_self.callbacks.didPause.call(_self);
};
}
this.stop will stop the track and clear the interval timer using
window.clearInterval(interval) . The stop method will also set the current
state of the track to 0 or STOPPED using state = _self.state.STOPPED . This
method will also reset the current time and make a call to the didStop callback
method.
Search WWH ::




Custom Search