duration
How can I get the html5 audio’s duration time
2020 solution: You will get undefined or NaN (not a number) when the audio metadata isn’t loaded yet. Therefore some people suggested to use onloadedmetadata to make sure the metadata of the audio file is fetched first. Also, what most people didn’t mention is that you have to target the first index of the audio … Read more
Formatting a Duration in Java 8 / jsr310
Java 9 and later: Duration::to…Part methods In Java 9 the Duration class gained new to…Part methods for returning the various parts of days, hours, minutes, seconds, milliseconds/nanoseconds. See this pre-release OpenJDK source code. Given a duration of 49H30M20.123S… toNanosPart() = 123000000 toMillisPart() = 123 toSecondsPart() = 20 toMinutesPart() = 30 toHoursPart() = 1 toDaysPart() = … Read more
current/duration time of html5 video?
HTML: <video id=”video-active” class=”video-active” width=”640″ height=”390″ controls=”controls”> <source src=”https://stackoverflow.com/questions/6380956/myvideo.mp4″ type=”video/mp4″> </video> <div id=”current”>0:00</div> <div id=”duration”>0:00</div> JavaScript: $(document).ready(function(){ $(“#video-active”).on( “timeupdate”, function(event){ onTrackedVideoFrame(this.currentTime, this.duration); }); }); function onTrackedVideoFrame(currentTime, duration){ $(“#current”).text(currentTime); //Change #current to currentTime $(“#duration”).text(duration) } Notes: Every 15 to 250ms, or whenever the MediaController’s media controller position changes, whichever happens least often, the user agent must … Read more
Measuring elapsed time in python
For measuring elapsed CPU time, look at time.clock(). This is the equivalent of Linux’s times() user time field. For benchmarking, use timeit. The datetime module, which is part of Python 2.3+, also has microsecond time if supported by the platform. Example: >>> import datetime as dt >>> n1=dt.datetime.now() >>> n2=dt.datetime.now() >>> (n2-n1).microseconds 678521 >>> (n2.microsecond-n1.microsecond)/1e6 … Read more
Converting Java to Scala durations
I don’t know whether an explicit conversion is the only way, but if you want to do it right FiniteDuration(d.toNanos, TimeUnit.NANOSECONDS) toNanos will return the total duration, while getNano will only return the nanoseconds component, which is not what you want. E.g. import java.time.Duration import jata.time.temporal.ChronoUnit Duration.of(1, ChronoUnit.HOURS).getNano // 0 Duration.of(1, ChronoUnit.HOURS).toNanos // 3600000000000L That … Read more
How to get the duration of an audio file in iOS?
In the ‘File Attribute Keys’ of the NSFileManager class reference you can see that there is no key to use that will return the duration of a song. All the information that the NSFileManager instance gets about a file is to do with the properties of the actual file itself within the operating system, such … Read more
How to format a duration as HH:mm?
There is no need to use formulas for that, you can define your own custom formats. Just go to Format -> Number -> More formats -> More date and time formats. It will open a window with several date and time formats to choose from. You can define your own as well, using the upper … Read more
What does ‘PT’ prefix stand for in Duration?
As can be found on the page Jesper linked to (ISO-8601 – Data elements and interchange formats – Information interchange – Representation of dates and times) P is the duration designator (for period) placed at the start of the duration representation. Y is the year designator that follows the value for the number of years. … Read more