Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Applications > Incorrect "Total Time" in iTunes XML library?

Incorrect "Total Time" in iTunes XML library?
Thread Tools
timmerk
Mac Elite
Join Date: Jan 2001
Status: Offline
Reply With Quote
Aug 27, 2009, 06:51 PM
 
I'm writing a program to read in the durations of the songs in the iTunes Music Library.xml file. However, I'm noticing that the numbers are not equal to the duration reported in iTunes or Quicktime. I assumed the Total Time number was in milliseconds, but dividing them by 1000 and then by 60 is returning a minute duration that is anywhere between 20-40 seconds off of what the actual duration is.

Any ideas? Thanks!
     
cgc
Professional Poster
Join Date: Mar 2003
Location: Down by the river
Status: Offline
Reply With Quote
Aug 27, 2009, 07:28 PM
 
Do you take the decimal (subtract the whole number) and multiply that by 60 to get the number of seconds?

For example, if a group of songs were 12970987 mS duration, divide that by 1000, then divide it again by 60 to get roughly 216.1831167 minutes. Subtract 216 from that leaving the decimal and multiply it by 60 to convert the fractional minutes to actual seconds which is 10.987. So 12970987 mS is equal to 216 minutes and 11 seconds (rounded). You could do the same thing with the minutes and divide 216 by 60 which equals 3.6 hours then subtract 3 and multiply by 60 leaving 36 minutes.
     
TETENAL
Addicted to MacNN
Join Date: Aug 2004
Location: FFM
Status: Offline
Reply With Quote
Aug 27, 2009, 07:33 PM
 
It's correct for the first two songs in my XML library.

Did you consider the difference between the decimal and duodecimal system when dealing with time (ie. a 4.5 minute song is 4 minutes and 30 seconds)?
     
timmerk  (op)
Mac Elite
Join Date: Jan 2001
Status: Offline
Reply With Quote
Aug 27, 2009, 07:35 PM
 
Ah, that worked, thanks!

Edit: multiplying decimal by 60, which I think both are you were saying
     
   
Thread Tools
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 02:09 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,