I’m trying to guess the width-height of a random movie loaded in a movie view, so I can adjust its size programmatically. If I understand this “call method” thing, this should be something as:
tell application "Studio App" --> testing from outside
tell window 1
set m to movie of movie view 1
set qt to call method "QTMovie" of m --> * BAD
call method "attributeForKey:" of qt with parameters {"QTMovieNaturalSizeAttribute"}
end tell
end tell
From the docs:
So, what does it mean this “opaque pointer” thing? Apparently, “opaque” means it won’t return a value, so I can’t use it later to invoke the “attributeForKey:” method…
What would be the way to get this “QTMovieNaturalSizeAttribute”?
(I’ve considered using System Events and the “movie file” class, but seems very slow agains a “call method”?)
OK. I think I’ve found the thing, but now I can’t use the returned value. I added the QTKit framework and used this code:
tell application "Floating Toones"
tell window 1
set m to movie of movie view 1
set qtm to call method "movie" of class "QTMovie" of m
set qts to call method "attributeForKey:" of qtm with parameter "QTMovieNaturalSizeAttribute"
end tell
end tell
This returns something as “item id blah of…”. How can I convert this info to a AS-readable thing?
have you looked at using iMagine Photo to get this information. It can get the natural bounds {left, top, bottom, right} from the movie, or obtain any individual frame to save as a jpg or any other file type.
There will be a short delay when iMagine Photo starts, but once it is running using iMagine Photo to obtain properties about a movie or movies should be quite quick.
The movie importer object in iMagine Photo contains many features in common with the graphic importer so to use it you should check out both the movie and graphic importer sections of the documentation.
Or if you check out iMagine Photo’s applescript dictionary, both the graphic importer and movie importer inherit from the importer class which is defined in the “Type Definition Suite” and the graphic and movie importers are both defined in the “iMagine Photo Suite”.
As to your issue of opaqueness, it doesn’t mean it doesn’t return a value. Instead it would be like in applescript where you created a class and defined properties in that class. An opaque reference would be a reference where you could not access those properties from that reference. But if you defined some handlers in the class you can still call those, so you could write a handler to get the value of the property from the class. The handlers would be like the methods you call using your “call method” approach.
Yes, there are lots of way, including iMagine Photo, but I’d prefer Studio’s built-in “call method” so I don’t rely on third-parties (speed, portability)…
That’s because I’m looking for a way to “coerce” such NSValue to any of the supported data-types (eg, NSSize or NSPoint, whatever thing can return a list of AS-reals, or even a NSString, or whatever).
The project uses a QTMovieView and allows you to load a movie on the fly and then retrieve properties about the movie (current width & height, default width & height, duration, and current time).
I just revised the project a bit and removed the build folder so it is a much smaller download. The revised project uses the properties of the movie to change the size and title of the window containing the movie view:
Seems it doesn’t work the same for a NSMovieView (against a QTMovieView). I’ve tried something as:
But it returns allways “0.0” and “0.0”. This must be a bug in the compiler, or just that this is my first time hacking obj-c code
I would pass the “NSValue” to the function (returned from “QTMovieNaturalSizeAttribute”), and it would just “coerce” both width and height to numbers in a NSDictionary, but I don’t know how extract these values (etc.)…
I’ve tried hacking your code, but it didn’t work neither… I would study the possibility of using a QTMovieView if I don’t finally find the answer for this issue… I’m working in a little sample called “Floating Toones”, which is a mix of hacked code, where the main goal is displaying animated-floating-transparent-draggable cartoons. The main part is done (I’ll publish it here when it’s done), but I would like add a little auto-resize and auto-position function based on the movie’s bounds. It’s not important, but maybe useful for end-users…
Um, why are you fighting using QTMovieView if you are willing to use QTKit? NSMovieView is deprecated in favor of QTMovieView. Also, I believe your method is returning the proper value. When you use the construction: ‘call method “movie” of class “QTMovie” of m’, I think this returns an empty QTMovie object, not the QTMovie object of your movie. For instance, if you do this:
set m to movie of movie view 1 of window 1
set qtm to call method "movie" of class "QTMovie" of m
call method "getProperties:" of class "methods" with parameter qtm
and then in your methods class, just use this code:
+ (void)getProperties:(id)movie {
NSLog(@"%@", movie);
}
You should see something like:
In fact, I’m fighting against I-don’t-know-why. I’ve picked code and ideas from various sources for a personal project, and now I was trying to create a template, or sample project, so I could share it with someone else. The skeleton comes from Apple’s “RoundTransparentWindow” sample project, and it’s mixed with some lucky discoveries, including Flash movies (QT-compatible = Flash 5) with alpha.
At this point, I don’t know if I could reproduce all the “interesting” behaviours in a QTMovieView: transparency and drag-ability (using the “RoundTransparentWindow” framework). And, as I “finished” my personal project, I’m not interested anymore in this template-for-someone-else (unless I find a quick way to implement the auto-resize-and-position code based on the movie’s size).
Seems that the QTKit isn’t “fully implemented” in Studio, so I should use various “call method” to setup things properly (eg, hiding the controller, playing the movie and perhaps something else). At this point, it isn’t worth the effort (I think).
Thanks! The new “methods” file did the trick (I saw before “GetMovieNaturalBoundsRect” in the docs, but couldn’t guess how make it work…). OT: is it difficult Obj-c?