Q: Units of duration in QTP7
I am using AppleScript to play audio through QTP7, employing the following key lines:
tell application "QuickTime Player 7" to play document 1
repeat
display dialog "Interrupt" buttons {"Stop", "Pause"} giving up after my secLeft()
--etc
end repeat
on secLeft()
tell application "QuickTime Player 7"
tell document 1
set d to (duration - current time)
end tell
end tell
--set d to round d * 0.00166 rounding down -- library pop music
--set d to round d * 0.00002268 rounding down -- library classical music
return d
end secLeft
Display dialog disappears after a number of seconds set by secLeft().
One would suppose, that duration and current time are given in seconds too, but that is not the case, so I have to correct d to express it in seconds.
I have two iTunes libraries with each a different correction factor; within a library the correction factor is the same for each song, at least I hope so, and until now that seems to be the case.
Until recently duration and current time were expressed in seconds in QTP, but after updating to Mountain Lion I ran into problems; the switch to QTP7 could also be the culprit.
My questions:
1. Why are duration and current time not simply expressed in seconds?
2. More importantly, what determines the correction factor and what can I expect for my next iTunes library?
Maybe I should address these questions to the designers of AppleScript of QTP7, but where?
iMac, OS X Mountain Lion (10.8.2), FileMaker Pro 11
Posted on Jan 22, 2013 7:29 AM
My answer to both of you, Pierre L. and Camelot.
I am always amazed at the depth of your knowledge.
I know just enough of AppleScript to realize what cannot be done in FMP.
Let me first tell you what I found out before I read your answers.
Apparently because of Mountain Lion AppleScript no longer reads the duration of iTunes, expressed in milliseconds, but the underlying duration in the music file, which is translated by iTunes into milliseconds.
It took me a day to figure out, that the difference lies in the type of music file, mp3 or m4a (also AAC).
My classical music library is fairly recent and all music was imported as m4a files; the popular music library is older and consists of 90% mp3 and 10% m4a files.
I ran Chiquita and the data were different, because my Chiquita is a mp3 file.
In fact, the mp3 time scale of 600 corresponds to my factor 0,00166, the m4a time scale to my factor 0.00002268, as uou both indicated.
So I will use the time scale to determine what type the audio file is - I hadn't yet figured that out - and then apply the corresponding correction factor bij dividing by 600 or 44100.
Thanks for your inspiration, and yes I shall be bold enough to study the article.
Posted on Jan 23, 2013 11:53 AM