javascript - Converting an <audio> tags track time into Mins:Secs -


i created frankensteined audio player, , need little track timing. have counts 0 -> whatever track time is, in seconds. can't seem figure out how convert seconds mins:secs.

i'm new timing/converting js, appreciated!

html

    <audio src="" id="player"          ontimeupdate="document.getelementbyid('tracktime').innerhtml = math.floor(this.currenttime) + ' ' + math.floor(this.duration);">\ </audio>       <span id="tracktime">0  0:00</span> 

code update

alright, have shows minutes single digit (ie: 1:00 = 1, 2:00 = 2, 3:00=3, etc)

i need show 3 digits, ie: 1:00 = 1:00, 2:00 = 2:00, etc.

here current audio tag:

<audio src="http://dosh.dk/bb/track.mp3" id="player" ontimeupdate="document.getelementbyid('tracktime').innerhtml = math.floor(this.currenttime / 60) + ' ' + math.floor(this.duration / 60);">     <script>       var minutes = math.floor(time / 60);        var seconds = time - minutes * 60;        var hours = math.floor(time / 3600); time = time - hours * 3600;        function str_pad_left(string,pad,length) {     return (new array(length+1).join(pad)+string).slice(-length); }       </script>      </audio>  

i can't seem concatenate seconds onto minutes.

figured out, had reformat somethings..

html

<div class="scrub-bar">       <div class="progress"></div>       <div class="time current">0:00</div>       <div class="time duration">0:00</div> </div> 

js

//var audio = link audio file     audioplayer.addeventlistener("ended", replay, false);     audioplayer.addeventlistener("timeupdate", timeupdate, false);      function reskintime(secs, format) {             var hr = math.floor(secs / 3600);             var min = math.floor((secs - (hr * 3600)) / 60);             var sec = math.floor(secs - (hr * 3600) - (min * 60));             if (sec < 10) {                     sec = "0" + sec;             }             return min + ':' + sec;     }      function timeupdate() {             playpercent = (audioplayer.currenttime / duration) * 100;             playhead.style.width = playpercent + "%";             timer.innerhtml = reskintime(audioplayer.currenttime.tostring());     } 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -