duration

PHP: How to convert string duration to ISO 8601 duration format? (ie. “30 minutes” to “PT30M”)

亡梦爱人 提交于 2019-11-29 18:06:43
问题 There are plenty of questions asking how to do this the other way (converting from this format), but I cant find anything on how to output in the ISO 8601 duration format in PHP. So I have a heap of duration strings in human readable format - I want to convert them into the ISO 8601 format on the fly to print the durations for HTML5 microdata. Below is a sample of some of the strings coming in, and how they should be formatted "1 hour 30 minutes" --> PT1H30M "5 minutes" --> PT5M "2 hours" -->

Java format hour and min

主宰稳场 提交于 2019-11-29 12:05:08
I need to format my time string such as this: int time = 160; Here's my sample code: public static String formatDuration(String minute) { String formattedMinute = null; SimpleDateFormat sdf = new SimpleDateFormat("mm"); try { Date dt = sdf.parse(minute); sdf = new SimpleDateFormat("HH mm"); formattedMinute = sdf.format(dt); } catch (ParseException e) { e.printStackTrace(); } return formattedMinute; // int minutes = 120; // int h = minutes / 60 + Integer.parseInt(minute); // int m = minutes % 60 + Integer.parseInt(minute); // return h + "hr " + m + "mins"; } I need to display it as 2hrs 40mins.

HTML5 Audio Player Duration Showing Nan

两盒软妹~` 提交于 2019-11-29 11:44:56
问题 I just started to learn HTML5 and was going through HTML5 Audio player using JQuery. I coded a player with Playlist, everything works fine except the Duration with help of which my input range slider doesn't works. When I debugged I found that my duration is showing me NAN. I am setting the duration after the song is initialized. Here is my JS code jQuery(document).ready(function() { container = $('.container'); playList = $('#playlist'); playListSong = $('#playlist li'); cover = $('.cover');

Bootstrap 4 Carousel: Individual data-interval on each slide

主宰稳场 提交于 2019-11-29 10:55:23
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 the site. Here is the js code: var t; var start = $('#carouselExampleFade').find('.active').attr('data

AVPlayer cannot resume upon Wifi drops in iOS 8

人盡茶涼 提交于 2019-11-29 07:04:55
I'm using AVPlayer to play streaming video. When Wifi drops and later enables, I see that AVPlayer cannot resume, no matter how many times I call AVPlayer play , and its currentItem 's duration is NaN, seekableTimeRanges is empty. This is not the case for iOS 7, it resumes and plays well. The workaround I can think of is to restart the player. How to deal with this? 来源: https://stackoverflow.com/questions/28059019/avplayer-cannot-resume-upon-wifi-drops-in-ios-8

How can I get the html5 audio's duration time

こ雲淡風輕ζ 提交于 2019-11-29 01:05:41
I have a html5 <audio> tag in page, but how can I know its duration time? <audio controls=""> <source src="p4.2.mp3"> </audio> Which browser are you trying this on? On some browsers duration doesn't work as it should, returning NaN as you mentioned. Also are you ensuring that the audio file has loaded before attempting to retrieve the duration? Fábio Zangirolami var au = document.createElement('audio'); au.addEventListener('loadedmetadata',function(){ au.setAttribute('data-time',au.duration); },false); 2018 solution: You will get undefined or NaN (not a number) when the audio metadata isn't

get duration of audio file

孤者浪人 提交于 2019-11-28 16:31:22
问题 I have made a voice recorder app, and I want to show the duration of the recordings in a listview. I save the recordings like this: MediaRecorder recorder = new MediaRecorder(); recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT); folder = new File(Environment.getExternalStorageDirectory() + File.separator + "Audio recordings"); String[] files = folder.list(); int number = files.length + 1; String filename = "AudioSample"

How to get the duration of an audio file in iOS?

安稳与你 提交于 2019-11-28 15:10:08
问题 NSDictionary* fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:filename error:nil] From the file attribute keys, you can get the date, size, etc. But how do you get the duration? 回答1: 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

Find weekly periods (starting on a Monday) for a month

牧云@^-^@ 提交于 2019-11-28 09:34:22
I'm trying to find the weekly periods for a given month and year. Dates should start on a Monday and end on a Sunday. If the 1st of the month is a Sunday (Ex May 2011), it should be the first element. May 2011 May 1 (Sunday) May 2 - May 8 (Monday - Sunday) May 9 - May 15 (Monday - Sunday) May 17 - Ma6y 22 (Monday - Sunday) May 23 - May 29 (Monday - Sunday) May 30 - May 31 (Monday - Tuesday) September 2012 September 1 - September 2 September 3 - September 9 September 10 - September 16 September 17 - September 23 September 24 - September 30 I am using this function to calculate the week numbers

MySQL storing duration time - datatype?

▼魔方 西西 提交于 2019-11-28 07:16:49
I need to calculate the time a user spends on site. It is difference between logout time and login time to give me something like "Mr X spent 4 hours and 43 minutes online". So to store the4 hours and 43 minutes i declared it like this: duration time NOT NULL Is this valid or a better way to store this? I need to store in the DB because I have other calculations I need to use this for + other use cases. Storing it as an integer number of seconds will be the best way to go. The UPDATE will be clean and simple - i.e. duration = duration + $increment As Tristram noted, there are limitations to