duration

YouTube Player API: How to get duration of a loaded/cued video without playing it?

故事扮演 提交于 2019-11-28 05:06:05
I'm not able to get the correct video duration/length (in seconds) of a loaded/cued video via the getDuration() method of the YouTube Player API; the same method, however, returns a valid value once the video starts playing! Wondering how YouTube is able to show the valid duration of a loaded/cued video. When I load this HTML page with a 15 second video clip, I get the following debug output: state = 5 duration = -0.000025 When I hit the Play button, I get the following debug output: state = 3 duration = 15, Would greatly appreciate a solution or a workaround. Loading, and immediately playing

Bootstrap 4 Carousel: Individual data-interval on each slide

眉间皱痕 提交于 2019-11-28 01:14:58
问题 I want to set the data-interval for each slide of the carousel. Here on stackoverflow I found a JavaScript snippet for this case, but it doesn't work well. (Twitter Bootstrap Carousel slide duration) Each slide has its data-interval set inline in html with ms from 3000 to 7000 on five slides. The real duration of the slides does not fit to my expectations and the code. Example: I set the interval to 3000 and the slide is shown around 7-8 seconds. The js-file is written in the footer area of

Java: How to convert a string (HH:MM:SS) to a duration?

我是研究僧i 提交于 2019-11-27 22:06:55
i want to convert a string with a format of HH:MM:SS or MM:SS or SS into a datatype of Duration. solution: private ArrayList<Duration> myCdDuration = new ArrayList<Duration>(); private void convert(String aDuration) { chooseNewDuration(stringToInt(splitDuration(aDuration))); //stringToInt() returns an int[] and splitDuration() returns a String[] } private void chooseNewDuration(int[] array) { int elements = array.length; switch (elements) { case 1: myCdDuration.add(newDuration(true, 0, 0, 0, 0, 0, array[0])); break; case 2: myCdDuration.add(newDuration(true, 0, 0, 0, 0, array[0], array[1]));

How to get the precision of high_resolution_clock?

左心房为你撑大大i 提交于 2019-11-27 21:11:06
C++11 defines high_resolution_clock and it has the member types period and rep . But I can not figure out how I can get the precision of that clock. Or, if I may not get to the precision, can I somehow at least get a count in nanoseconds of the minimum representable time duration between ticks? probably using period ? #include <iostream> #include <chrono> void printPrec() { std::chrono::high_resolution_clock::rep x = 1; // this is not the correct way to initialize 'period': //high_resolution_clock::period y = 1; std::cout << "The smallest period is " << /* what to do with 'x' or 'y' here? */ <

Measuring elapsed time in python

放肆的年华 提交于 2019-11-27 17:41:40
Is there a simple way / module to correctly measure the elapsed time in python? I know that I can simply call time.time() twice and take the difference, but that will yield wrong results if the system time is changed. Granted, that doesn't happen very often, but it does indicate that I'm measuring the wrong thing. Using time.time() to measure durations is incredibly roundabout when you think about it. You take the difference of two absolute time measurements which are in turn constructed from duration measurements (performed by timers) and known absolute times (set manually or via ntp), that

C# - Duration between two DateTimes in minutes

走远了吗. 提交于 2019-11-27 17:21:38
问题 I need to determine duration between two DateTimes in minutes. However, there is a slight twist: exclude weekends only count minutes which are between 7:00AM and 7:00PM. for example: [09/30/2010 6:39:00 PM] - [09/30/2010 7:39:00 PM] = 21 Minutes I'm just having a hard time coming up with a decent way to do it and would appreciate if anyone can suggest something. Thanks. Edit: I ended up going with dtb's solution. There is only one special case which needed to be taken care of: if end time is

What is the best way to get an audio file duration in Android?

送分小仙女□ 提交于 2019-11-27 16:17:34
问题 I'm using a SoundPool to play audio clips in my app. All is fine but I need to know when the clip playback has finished. At the moment I track it in my app by obtaining the duration of each clip using a MediaPlayer instance. That works fine but it looks wasteful to load each file twice, just to get the duration. I could roughly calculate the duration myself knowing the length of the file (available from the AssetFileDescriptor) but I'd still need to know the sample rate and the number of

PHP: add seconds to a date

只谈情不闲聊 提交于 2019-11-27 15:59:09
I have $adate; which contains: Tue Jan 4 07:59:59 2011 I want to add to this date the following: $duration=674165; // in seconds Once the seconds are added I need the result back into date format. I don't know what I'm doing, but I am getting odd results. Note: both variables are dynamic. Now they are equal to the values given, but next query they will have different values. If you are using php 5.3+ you can use a new way to do it. <?php $date = new DateTime(); echo $date->getTimestamp(). "<br>"; $date->add(new DateInterval('PT674165S')); // adds 674165 secs echo $date->getTimestamp(); ?> Just

Convert seconds to human readable time duration

冷暖自知 提交于 2019-11-27 13:58:09
How would I best convert 90060 (seconds) to a string of "25h 1m"? Currently I'm doing this in SQL: SELECT IF( HOUR( sec_to_time( sum(time_to_sec(task_records.time_spent)) ) ) > 0, CONCAT( HOUR(sec_to_time(sum(time_to_sec(task_records.time_spent)))), 'h ', MINUTE(sec_to_time(sum(time_to_sec(task_records.time_spent)))), 'm' ), CONCAT( MINUTE(sec_to_time(sum(time_to_sec(task_records.time_spent)))), 'm' ) ) as time FROM myTable; But I'm not sure it's the most convenient method :-) I'm open to suggestions on doing this both in SQL (differently than I'm already doing) or in PHP. EDIT: Examples of

time.Since() with months and years

試著忘記壹切 提交于 2019-11-27 13:36:11
I am trying to convert a timestamp like this: 2015-06-27T09:34:22+00:00 to a time since format so it would say like 9 months ago 1 day 2 hours 30 minutes 2 seconds. something like that. I used time.Parse and time.Since to get to this: 6915h7m47.6901559s But how do I convert from there on? Something like this is what I thought: for hours > 24 { days++ hours -= 24 } But the issue with this is that this won't be accurate for months because months can have 28, 30 and 31 days. Is there a better way of achieving what I want? The days in a month depends on the date, just like the days in a year (leap