function AudioPlayerTimer(){
    var startPosition, elapsedTimeMs, isPlaying = false;

    var getCurrentOffsetInMilliseconds = function(){
        return (Date.now() - startPosition);
    };
    this.start = function(){
        startPosition = Date.now();
        isPlaying = true;
    };
    this.stop = function(){
        if(isPlaying){
            elapsedTimeMs += getCurrentOffsetInMilliseconds();
            isPlaying = false;
        }
    };
    this.reset = function(startP){
        elapsedTimeMs = startP;
        isPlaying = false;
    };
    this.getOffsetInMilliSeconds = function(){
        var offset = elapsedTimeMs + (isPlaying ? getCurrentOffsetInMilliseconds() : 0);
        return offset;
    }
}