I understand the the above code and can get it to work if i import the .m & .h files from an existing example. The problem is that don’t need the other 1000 lines of code in the files.
I have tried my utmost to convert to ASOBJC. When i log the current time , I get a weird value that i can’t replicate as i have screwed all my code up! The value is some sort of array that has something like the following in it “kisd <0000000000hj> ssid blah blah”
I have created the movie object with QTMovieOpenForPlaybackAttribute and i can control it, change aspect ratio, get it to loop etc, but what seems to be the easiest function of getting the currentTime has stumped me!
Here are some of the crazy ways i have tried
QTTime’s valueWithQTTime(theMovie’s currentTime)
theMovie’s attributeForKey_QTMovieCurrentTimeAttribute_()
theMovie’s QTStringFromTime(currentTime)
theMovie’s QTTime’s valueWithQTTime(theMovie’s currentTime)
current application’s theMovieView’s theMovie’s currentTime()
set thetime to QTTime’s currentTime(theMovie)
current application’s class “QTTime”'s currentTime()
( to name a few)
Please can someone point me in the right direction
set currentPlayTime to theMovie's attributeForKey_("QTMovieCurrentTimeAttribute")'s QTTimeValue()
set theString to current application's QTStringFromTime(currentPlayTime)
or:
set currentPlayTime to theMovie's attributeForKey_(current application's QTMovieCurrentTimeAttribute)'s QTTimeValue()
set theString to current application's QTStringFromTime(currentPlayTime)
The problem is that QTStringFromTime is a function, not a method, and it may not work.
But what’s your objection to the Objective-C code? Can’t you trim it? And if not, does it matter?
I had this same question a couple of months ago, and got the same error I’m getting wtih your sample.
“can’t bridge argument of type {?=qqq}.” There appear to be some things that ASOC can’t do.
My objection is my inability to understand it (yet)…and if you or Pezwell can trim it and give a quick example how I can use it in my app, I’d be greatly appreciative. I’ve “worked around” the issue by ignoring it . It’s not necessary for my app, but would be very very useful!
That’s right. It can only deal in objects, such as NSNumbers and NSStrings. It can also deal in ints, floats, NSRanges, and a couple of other non-object types by converting them to objects, but any other non-object types are off-limits. QTTime is a struct, not an object type.
Add the QTKit.framework to your project.
Something like this:
Add a new Objective-C class to your project (New → File), and call it something like CallQTStuff.
Add a new NSObject blue cube to your .xib, and change its class to CallQTStuff.
Add a property to your script, set its value to missing value, and in the interface connect it to the blue cube representing CallQTStuff. Let’s say it’s called myQTCollection.
When you want to get the time, call it like this:
set theString to myQTCollection's currentTimeFromMovie_(theMovie)
Thank you so much - Worked perfectly for my purpose! As always, I really appreciate your posts here and have found your book and it’s examples indispensable. Without your help, my app wouldn’t do 1/10th what it does
curTime is a C structure containing two members: the elapsed time and the frame rate.
To coerce it to something readable the function QTStringFromTime() is needed
I am happy to email you my project if you would like to have a look at it. It is a little messy as it is a test project and
it is filled with lots of code examples that work ( but placed in the incorrect places - i am a bit of lazy programmer)
Essentially I have been getting certain code to work then transferring it to a proper project. But as it stands the test project has the following working code.
-Fade a movie in and out while playing.
-Plays full screen ( cmd + F ) - 10.6 code - not the new 10.7 fullscreen options
-Show or hide the movie controller
-Toggle Movie Aspect ratio
-Uses timers to display current time and duration of movies
-Sets the window background to black
-Pause and play
-Go back to the beginning of a movie
-Auto loads a specific movie at startup ( you would need to change the path to a movie on your system)
-etc
There are no interface buttons and all the code is linked to key presses.
As it stands I am able to get the duration of a movie and the current time ( both as string). What I am bring to achieve at the moment is to get a time comparison of the current time and the duration to check if the movie is about to end so i can cross fade between the next movie.
Basically in natural language I want to say:
If movie’s ( duration - current time) => movie’s ( duration - 1 second ) then
do cross fades
end if
I can go the long way and change the strings back to numbers but I want to try implement QTKIT_EXTERN NSComparisonResult QTTimeCompare (QTTime time, QTTime otherTime) as per the documentation.
As it stands i have used Shane’s above code and get a current time string and a duration string using the following
I want to add a third option using the QTKIT_EXTERN NSComparisonResult QTTimeCompare (QTTime time, QTTime otherTime) but I have no idea how to translate the documentation into the .m and . h file in the required structure.
Any pointers will be HUGLEY appreciated
QTTimeCompare will just tell you if the first time is bigger than, equal to, or smaller than the second, which is not what you want. QTTimeDecrement is probably the answer, something like this: