QuickTime • 1:10:06
QuickTime is the most powerful cross-platform digital media platform available, but are there alternatives to CodeWarrior and Microsoft Developer Studio for QuickTime development? View this session to see how to build QuickTime applications with REALbasic, Visual Basic, Runtime Revolution, and some of the other available alternatives. No prior experience with these tools is required, but you should have a basic knowledge of QuickTime to get the most from this session.
Speakers: Tim Monroe, Keith Gurganus
Unlisted on Apple Developer site
Transcript
This transcript was generated using Whisper, it has known transcription errors. We are working on an improved version.
Thank you very much. The first question you should have is, alternative to what? And I would guess that somewhere between 99 and 100% of people developing QuickTime software right now are using a fairly restricted set of tools. Either they're programming in straight C, or they're maybe using an object-oriented language like C++, or Objective C, or Objective C++, or even Java. And these are all of a family of C-oriented tools.
What I want to look at today is some other programming environments that we could use to develop QuickTime applications. So, what are we going to learn today? Well, that's me and Keith. We're going to look at how to build a QuickTime application, and we're going to do it in 10 minutes or less. And for several of these environments, we're going to do it in 10 lines of code or less.
Once we've done that, we're going to look at some ways to extend these built-in support for QuickTime in each of those application environments. Along the way, we will encounter some limitations that these various environments have, and we'll also look at some ways to work around those. Finally, at the end, I will give some guidance to the people developing those development environments as to how I think they could be made even better than they are now. We've got a full plate today. We may not get to Q&A, but I think you'll enjoy what we've got.
So, these are the standards that, as I recall, I'm guessing most people are using to develop QuickTime applications. MetroWorks CodeWarrior on Mac and Windows, probably using C++ and perhaps the PowerPlant application framework. If you're developing for Windows only, you're probably using Microsoft Developer Studio, possibly with MFC application framework. And if you're developing for Mac only, chances are you're using the new Apple IDE.
So what are some of the alternatives? Well, I went casting about to see what I could use to build QuickTime applications without resorting to those old standards. And I came across at least these eight. And if anybody knows any other ones, I'd love to hear about them. I don't have time to talk about eight different programming environments today, so I'm going to pick the top four there.
These are all similar in many ways, as we'll see. And one nice feature that they have in common is that they're what we call rapid application development tools. The idea being that in very little code, with very little pain, and indeed, as I've claimed, in 10 minutes or less, you can get an application up and running that will do what you want. So let's... I'm not going to build a full multi-document application in any of these. So I've got to sort of limit what I want to achieve.
So for each of these four environments, I want to do three things, really. I want to be able to prompt the user, have the user select a QuickTime movie file. I then want to open that movie file in a window on the screen that is sized to contain just the movie and the movie file. movie controller bar.
So really there's three things. I want to find a file, I want to open the movie in the file, and I want to size the window to exactly contain the movie and its controller bar. Now, once I've done that, the hope is that the window will present all the standard means of interacting with the QuickTime movie. So basically, mouse and keyboard input should work as you expect it to.
And one final and very important item. Once I've done all that and I've got my movie open on the window, open in a window on the screen, it shouldn't matter what kind of QuickTime movie I've opened. QuickTime can handle a large range of different media types. Sometimes we tend to think of it as video and sound, but we have things like QuickTime VR, sprites, animation, flash. In the ideal world, each of these applications would handle those things perfectly.
"And let's show what I mean there. Can I get VGA 2, I guess? So I've got a selection here of I'm just going to drag them all onto a sample application. Now this is the kind of thing that most people would write. It's a C-based application. The code has been on the web for this for years. Here I've got your standard music video. Open in a window on the screen.
There really is audio here, I guarantee you. Okay, so that's what most people tend to think of as a QuickTime movie. Here's a different kind of QuickTime movie. This is a sprite movie, and this is a wired sprite movie. So I've got this little icon bouncing around inside the movie window. Here's a similar looking movie, but it doesn't bounce, but I can drag it if I come over here and click on it. So I'm getting mouse interaction there.
Here's a QuickTime video effect movie. It's a fire that just burns. Here's a QuickTime VR movie. This is a rendered panorama, not photographed. Again, it's got a different sort of controller bar down here. And finally, here's another wired sprite movie. If I click on the penguin, the other one moves around. Okay, so that's really the gold standard of the kind of interactivity that I need for each of these development environments.
First one I want to talk about is REALbasic, a very nice development environment. It's been around on the Macintosh for quite a while, and recently has been ported to work on Windows as well. It's published by a company called Real Software. As I said, it's a rapid application development tool. We'll get a better feel for what that means in just a second. The language we're going to use is an object-oriented variant of BASIC.
As I said, the IDE runs on Mac and Windows, and you can build applications on either IDE to run on Mac and Windows. And for present purposes, what we're interested in is that there's built-in support for playing QuickTime movies using what they call a movie player control. So I think we're ready for a demo of that.
So I'm going to come over here and launch REALbasic. I'm using version 4.5.2. There's actually a newer version out there, but I haven't got it yet and don't want to change horses in midstream. So when I launch REALbasic, I get an empty window here. That's going to be where the movie is. I have a window that shows me what's in my application right now.
I have a palette of tools that I can use, and then I have a properties window, which will tell me for the given selected tool what its properties are. So the first thing I'm going to do is grab this little QuickTime icon and drag it into my window. I want to put it up at the top left corner there. You can see the top is a negative one, so let's bring that down.
I want the movie to exactly fill the window, so I'm going to uncheck this border property. If I were, say, in part of a window, I might want a nice border to delimit the movie. And that's my setup for the window. I don't need to resize this control, although I could to fit the window.
I'm going to do that later programmatically with code. So let's do that. I'm going to double-click on the movie player control, and it brings up a code window. So I can attach code to elements of the interface here. I'm not interested in the play event. I want to attach some code to the open event.
So when this window opens and the movie player control opens, the code that I type here will be executed. So what do we want to do? Remember, I want to do three things. I want to find a file, open a movie in that file, and size it appropriately. So the way I get a file is get open. So I'm going to do a folder item. I need to tell it what kind of file I want. I'm going to want to open Video QuickTime. This is just a MIME type specification.
Okay, now this is going to present the standard file opening dialog box, and it's going to return to me a path name, or an item. Actually, not a path name, but an object called a folder item. So I'm going to say item is equal to the result of that, and since this is basic, I have to declare that variable, and it is of type folder item. Okay.
Notice there was the code completion. All I had to do was hit tab to get what I wanted there. Okay, once I have presented the file opening dialog box, the user has selected a QuickTime movie file because that's all they'll be able to select. I want to make sure that I got something, so... If item is not equal to nil, then I'm going to have a block of code.
Okay, and what am I going to do there? What is the object that this code is attached to? It's a movie player object. That movie player object has a property, what its movie is. So I can say myMovie or me.movie is what? It's the result of opening that item as an editable movie. Finally, I want to set the height and width appropriately so I can say "me.window.css". "Width equals what? It's going to be the controller Width of the movie that I just opened. And now I'm going to copy and paste that. Do the same for height. And height.
And I'm done. I can close that. In theory, I could run this, but actually it won't work. I need to do one further thing. I need to tell REALbasic what kind of file types I can open. So I'll call this up, and I will add There's this nice pop-up list that goes on forever.
Video QuickTime, it fills out all the parameters for me. OK, OK. Now let's try it. We can actually run this within the IDE by hitting Run. There's my file opening dialog box. I'll choose a nice music video here. It opens it, sizes it, and let's see if it works.
Perfect. So how many lines of code was that? It was one, two, three, four, five, six, seven, really. Seven lines of code, select a movie file, open it, size the window appropriately, and we're good to go. Let me... Save this here, because I'm going to come back to this later. I want to give it a name. Notice I've selected OS X build. Let's call it RB Demo.
Then I'll actually build a double-clickable application, and it nicely opens the finder up and shows me where it put it. Where did it put it? Let's put it on the desktop. Okay, let me do one more thing here. Let's run this again. Let's open that Fire Movie. Notice this. While I'm moving my mouse around, the fire burns. If I stop the mouse, the fire kind of sputters, and it's not getting events here. I can do the same thing if I go back and open the bouncing sprite movie.
While I'm moving my mouse around, events are getting processed, everything's hunky dory. When I stop, I get this jerkiness. I discovered, purely by chance, a real easy workaround. If I grab this timer tool, plunk it down there, give it, say, a 33 millisecond period. Now let's try running it again. FireMovie burns fine. So simple little clues there to make sure that events are sent to the movie and we can now, now we're happy. Okay, so that's REALbasic. Now I want to bring Keith up here to talk to us about Visual Basic.
I think most people have heard of Visual Basic, and what we want to do today is just do a simple application that opens a movie and plays that movie. So, as the slide says, it's a rapid application development. This is kind of interesting. I just did a little search on the web and found out that it is pretty much the biggest development environment used on Windows today. The latest version is VisualBasic.net, and that'll be the one I'll be using. A lot of people are still using Visual Basic 6, which is still pretty powerful.
What we're going to do is show how easy it is to hook into several of the ActiveX controls. And those controls, there's three of them that we'll look at and talk about, but we're going to use one, and the one we're going to use is from Skylark. ActiveX controls are just COM objects, and if you're familiar with development on Windows, they're used throughout a lot of the development.
They're very easy to add to Visual Basic. A little bit harder to use in C++ and C, but with Visual Basic, you basically drag them over and you can double-click and hook them up. The ones available active X controls for QuickTime, you get one with Apple Computer, and that's installed automatically with QuickTime.
[Transcript missing]
So the first thing I'm going to do is bring up the visualstudio.net environment here, and we're going to create a new application. Except that it's waiting to install some stuff here. Okay. So I'll come over here and just set a new project. And we're going to select Windows application.
What'll happen here, it'll create a basic application with one form. We could actually run this and this form would come up. Nothing would happen with it. So what you do over here, the first thing we want to do is if you look over in this far left, you'll see all the controls. These are ActiveX controls. And the first thing I want to do is I'm going to add a menu to mine and add a couple items to them. I'll add an open, whoops, I better name my menu.
Okay, I've added a few items. With these ActiveX controls, over in the far left, you'll notice that you have a bunch of them for doing check boxes, radio buttons, and you basically just drag them over. Sometimes you don't have ActiveX controls, these are the basic ones that come with it, that you will have to actually add to this list so you can drag it over first.
And to do that is a right mouse button click, and then you would go over to – that thing just disappeared. "Add/remove items, and then you could browse to your OCX ActiveX control and just add it into your list. Once it is in your list, you just drag it over to the form.
I'm just going to size it, fit the window. It's not necessary. We'll do some dynamic sizing in a second. Okay, so what we've done so far, we've created a base application, added a couple menus, and we've dragged the ActiveX control. Now what we have to do is add the code to connect all that and open up the movie. Let's do that next. So if you double click on one of the menu items, it brings you over. And I'll go back to the form itself. Let's do them all.
Okay, so it set up all these little menu items that it'll call when we select that. Now I have a, to save time and everything, I'm just going to copy some code here, but I'll go over the code itself. Just a couple routines here to size the movie, to open a movie, and bring up a file dialog. Lastly, if you program in C, you know that you have to, with this particular ActiveX control, you need to call initializeQtml.
Okay, this should pretty much do it for the code, and then I just should be able to call these functions, and if we're lucky enough, everything will work. So on the first one, what we want to do is call OpenMovie. The second one was a closed movie. And these are precooked functions that I had set up.
And the last one...
[Transcript missing]
So let's take a look at OpenMovie. You saw what Tim did before and basically brings up a file dialog. We do a little bit of, in this particular thing, we call, We just call new Open File Dialog and put in our types here, extension we're looking for, and then we call here to show the dialog.
And after that, we do a little sanity check to make sure that we got a good result. This is the real key in that the ActiveX control, and I can show you what happens here. We'll type one. And Visual Basic, if you do, oops, I didn't want to quite do that.
You can see all the functions that are available to you, and you can select those. So that's a really nice feature here, and you can see what that particular ActiveX control offers. So what I did, I just went ahead and precooked a couple things, and I set the movie controller to visible, and in this particular one, I set the open file dialog file name into the file name.
That is what it takes to open up a movie. After that, what we'll need to do is to size the movie. So we're looking at the natural height of the movie here. So I do a little calculations and get the natural width and height of the movie. And I add the movie controller. In this particular instance, we know it's 16, so I just add 16 to it. I think you probably want to do a little more work here and figure out if you're going to have a controller or not have a controller with it.
Down in the load of the actual form and the control, we're going to initialize QuickTime, and then when we exit, we're going to just terminate it. So if I type everything right and copy, we should have an application here. This is a demo version. So I come over and open. It opens a file dialog. I lost all my movies.
I'll just grab one of these. These are some of the movies that we had before. Also, I had set up a close. I could close it, or it automatically closes. Whoops. That wasn't supposed to happen. Okay, so we'll do the fire here. This is running good, huh? There we go. Let's try that again.
You know what I didn't do here? I didn't size the movie. So that's the thing here. There we go. Okay, you can see the amount of work here to put support for QuickTime is fairly minimal. It was really, if you look at the AX Skylight 1, there's only a handful of lines to do that, I think about four. So adding application support for using Visual Basic and QuickTime is fairly easy. Okay, I'll turn it back over to Tim.
Okay, before I move on to there, let me do something fun here. Was this my project from before with REALbasic? Let's hope. Okay. VGA2, are we there? Okay. So I just opened the REALbasic project that I had before. Let's go in here to Build Settings. Let's click one checkbox. Let's go in and give this thing a name.
[Transcript missing]
Okay, now I've got this little USB thingy that I'm going to hook in here. What I want to do is take that exe file and give it to Keith. So if all goes well there, it will mount. I'm going to copy. The Windows executable onto that little thingamajig.
Okay, I will now unmount it. Keith will now hook this into his USB port and see if it runs. So now can we go to VGA1?
[Transcript missing]
If you've ever had to port an application from Mac to Windows or Windows to Mac, I bet it was not as easy as clicking a checkbox, copying it onto your USB dongle, and moving it to another computer. So that's really powerful. That's just fantastic. Okay, can we go back to slides? So there's the basic portion of our talk.
I want to move on to the higher-level scripting language portion of our talk, and now I want to talk about RunTime Revolution. Of the four environments that I'm talking about today, this is the one that you may not be familiar with. Put out by a company in Scotland called RunTime Revolution. Again, it's a rapid application development tool. This time, the language is a descendant of HyperCards language, HyperTalk, and they call it Transcript.
Again, we get cross-platform development capability. The IDE runs on either Mac or Windows, and indeed on some versions of Unix, and you can build applications for Mac or Windows. And they do have built-in support for QuickTime using a movie player control. Let's get straight to a demo of that. So now we're back to VGA2.
So I will launch Revolution. This is the latest version, 2.0.1. If you've used earlier versions, I highly recommend you update to this. They've done a whole lot of work to make this latest version a real nice Aqua Mac OS X citizen. So here it opened a palette of tools, similar to what we've seen in Visual Basic and Real Basic.
Here's sort of an application browser. And I don't yet have an empty window. What I'm going to do is come up here and do new main stack. And I'm also going to get my cheat sheet up here, because you didn't really think I remembered all this stuff, did you? So there's my movie window. What I'm going to do then is come over here, select my QuickTime player control, drag it out, again set it to the top left, and I want to pull down my properties window on screen in theory.
So that's saying that the current selected object is Player 1. I want to give that a different name. I want to call that Movie... I want to turn on the controller, and I want to again turn off the border property, because I'm going to size it to fit the window.
Okay, now I want to give my movie window, I've clicked the window down here and not my player up here, so I want to give it a name. Let's call it MovieWindow. And I think I'm ready to add some code. Now I'm going to click in the movie window again, come up here and say Edit Script.
And it opens a script editor window. This is where I'll type my code that's associated with the movie window. So, again, I want to do something when the stack or the window first opens, and the way I do that is with onOpenStack. And notice if I hit return, I automatically get the end open stack. Very nice feature.
Remember, I want to select a file, open a movie, and size it appropriately. The way I select a file in transcript is by saying answer file. I can now give it a nice prompt, select a movie file, and I can tell it what type of files I want.
"No typos there, excellent. So when that returns, it's going to have the file name of the file that the user selected. So I want to set the file name of the player "MoviePlayer" is the result of the previous command I ran, which is the answer "file", so that file name will now get set as the file name of the MoviePlayer. That is to say, it will tell it what the movie is.
So that's get a file, and that's open the movie. Now I need to size things appropriately. Set width of me. Remember, I'm attaching code to the movie window, so I can refer to that object as me. Set the width of me to the width of... And I'll just copy.
[Transcript missing]
And now I need to do one final thing, which is set the rectangle occupied by the movie player control.
And that rectangle is going to be 0, 0, width of movie player, height of movie player. And I'm done. I will click Apply, close that window. So that's all the code I need to add. And that was what? That was a whole seven or eight lines of code. A couple final enhancements here. In the movie window, I don't want it to show the resize box, so in size and position, I'll turn off resizable.
And I think we're good to go. So let me first save this. Okay, something goes wrong. Desktop, good. Let me build the application. I need to set a few configuration settings here. Where was it? I want it on the desktop. I need to, so I'm set up for a Mac OS X application. I need to tell it what stack file, and in theory, where did I put it? There it is right there. And I think I'm good to go.
Okay, so I think I can quit that. It should be in this folder. There's my double clickable application. So there it is. It's put up the file selection dialog box. I will go to my movies folder. See what it does to... There it is. It resized it. Does it run fine? Is there some reason we're not getting audio here? It really does support audio. Okay, let's try a couple other of those movies just to make sure that it's good for all of our media types. Here's our QuickTime VR movie.
It works fine. Let's check the keyboard. I'm going to use the arrow keys here to pan around. That works fine. I'll use the shift key to zoom in. That works fine. Control key to zoom out. Everything is fine. Let me do one final one. Let's try our sprite movies.
Bouncing Sprite. Doesn't want to bounce. There's an issue here with getting time for the Sprite movie, and I haven't quite figured it out. I've been talking with the Revolution people, and I think we've figured out how to handle this, but just so you know that I'm not trying to hide anything here.
Okay, I think that's what we need to do with Revolution. I could do the same thing that I did with REALbasic, which is go back in and click the checkbox to build a Windows application. I could have Keith come back up here and run it on his Windows machine, and it would be exactly what you'd expect.
Okay, the last thing I want to talk about, or the last development environment, is AppleScript Studio. This is the newest of the bunch. It's put out by Apple Computer. Again, it's a rapid application development tool. The language now is good old AppleScript. So whereas you're used to having AppleScript control other applications, now you can have AppleScript control things in the same application. This is built on the Cocoa application framework, so we're looking at Mac-only applications and indeed a Mac-only development environment. So let's launch the demo of that.
I'm going to get to AppleScript Studio by launching Project Builder, which apparently has been renamed under my feet. You'll notice I'm doing everything here on Jaguar. I don't believe that the Revolution or REALbasic have had a chance to play with Panther yet. If they have, I don't know that they've certified their tools for Panther, so I'm doing it on Jaguar here. Okay, Project Builder is open. I'm going to open a new project. And right up here at the top of the list, beside from Empty Project, is AppleScript Application. So I'm going to select that. Let's call that AppleScript Studio Demo.
I didn't make up the name. What can I do? They've taken a lot of heat for that, I expect. Here's my project window, as it were, and I'll reveal a few things. I've got a file of AppleScript. It's actually currently empty because I haven't written any script yet.
I have another source. This is actually some Objective-C code. All it does is initialize the AppleScript kit and then say, let's start the application running. We don't need to change anything there. What we do want to do first is set up our user interface. So I'll open this nib file and... I didn't seem to get a new project here, so I'm going to start over.
Maybe I have one by that name already, so let's call it FooDemo. All right. Let's go back, open our nib file, which is our UI. I guess it wants to give me a movie view. Pretend that that was initially empty. So that's our movie window. You can see that I've got a palette of tools here, and there's a nice QuickTime logo, so let's drag that over here. As usual, I'll put it up at the top left just for kicks.
Now I want to open the info panel here. I'm actually done. That's all I'm going to put in this window, so I'll get rid of that. It shows me the attributes of my movie view there. Let's go to this panel, AppleScript. And I want to give that movie view a name, so let's call it MovieView. Again, as in these high-level scripting languages, I'm going to refer to things by name. I'm actually not going to attach any script to the movie view, but I will attach it to the window.
So it's already got a name there, so I don't know why I'm getting this. I thought I opened a new empty project, but that's the name I would have given it, Movie Window. And what I want to do is remember with REALbasic, we added some code to the open routine. With Revolution, we added some code to the open stack.
Now we want to add some code to when this window is opened. And the Cocoa terminology is when we awake from nib. Nib is the file that our resources are stored in here. And the script that we're going to attach is already said to be in the file foodemo.applescript.
Let me just check here that I've got everything. Let me go back here to its properties. I don't want it visible at launch time. That was the default, and I've turned off this deferred for various reasons. Okay, I think that might be all we need there. Let me go back to the AppleScript panel and do Edit Script.
You can see I've got just a skeleton here, and it says add my script here, so that's what I'll do. So it's an onAwakeFromNibHandler, and the object here is the object that the script is attached to, which is the window. So if I want to do anything to the window, I can call it the object.
So again, I'm going to look for, oh, how about five lines of code here? First, I'll define a local variable, setMovieView.
[Transcript missing]
And it is of the object. So the window has a movie view in it. The name of that movie view is movie view. So I've set the local variable movie view to the movie view. Okay. If everybody's confused, wonderful. That just keeps me from having to repeat this movie view, movie view of the object all the time.
Let us set another local variable, movie path, to what? Remember, I want to put up the file opening dialog box, so that's choose file. Could it get any easier? Once that's done, I want to set the movie "Of movie view, that's got a movie associated with it, To the result of loading the movie, which is MoviePath.
So choose file gives me back a path name. I put that into the local variable moviePath. I load the movie in that path and assign it to the movie associated with the movie view. And finally, I want to show the object which was initially invisible. So let's see what happens if we build that.
Who's bugging me here? Okay, now let's run it within the IDE. There's my file selection dialog box. I can open a movie. And what's wrong? It's the wrong size. Right? It's the size of the movie view. Why? I didn't add any code in to set the size of the movie window.
Right, let's go back to my code window. All I did was select a file, attach that movie in the file to the movie view, and make the movie window visible. I didn't do any sizing here. Why didn't I do any sizing? Because, unfortunately, there's no vocabulary built into AppleScript Studio that allows me to do that.
So in order to find the natural size of the movie, I need to go beyond AppleScript Studio. And this is actually a good segue. I think we're moving on to advanced QuickTime usage here. Can we have slides for a second? So far we've seen really, how much time did that take? 45 minutes, so just over 10 minutes per development environment.
We see that basic movie playback is easy. We haven't talked about movie editing. That can be a bit harder. Some of these environments support it automatically. Some of them don't. What about full access to the QuickTime APIs? What if I really want to have a REAL QuickTime application that does something more than just open movies and play them back? And this is a good opportunity to segue into that particular issue.
Let's go back to VGA2, please. So the problem we need to solve now is, how do I determine with an AppleScript Studio what the natural size of the movie was? Visual Basic, Runtime Revolution, Visual Basic all gave me that information. AppleScript Studio doesn't, so we have to go beyond it. Now this is the portion where I stop typing and use a canned project that I have.
So I'm going to open one that I did earlier. Let's look at the script. Ignore that for a minute. Everything other than that is what we did just a second ago. is our way of sizing the movie appropriately, and the key here is this call method instruction. Basically, call method says, all right, I'm Apple Script Studio, I'm good, but I can't do everything. So go call this other method and come back to me with whatever output it gives you.
What method am I calling? I'm calling a method called controller rect, and I'm going to pass it a parameter, namely the movie view, or the NS movie view for those Cocoa people. So somewhere out there in my application is defined this method, controller rect, and it's going to give me back a rectangle. And let's just briefly look at what I do with that rectangle.
I copy it to some local variables, I get the bounds of the window, and then I do a little bit of math to set the size of the window appropriately. The magic number 20 here is the size of the window title bar, because in Cocoa, when I size a window, I don't just give it the size of the content region, but I give it the size of the whole window.
So everybody should be happy with this, except for this magic little control erect method. Where does that come from? What I'm going to do, or what I have done, is add two files to my project called MovieCat, and what they do is define what's called a category on a Cocoa class.
A category is a way to add methods to an existing class without actually having the source code for that class. You can see what I've done here. I have said, there's this class out there, an existing class called NSApplication. I want to have this category called MovieCat, and it's going to have one additional method, namely control erect. It takes an NSMovie view and gives me back a rectangle. Let's look at how I implemented that. Amen.
Very easy stuff. It's just using QuickTime APIs. Fundamentally, it's calling getMovieNaturalBoundsRect on the movie, the actual QuickTime movie identifier. Where do I get that? Well, Cocoa allows me to get two useful items, the movie controller identifier and the QuickTime movie identifier. You can see I'm sending to the movie view the movie controller method. It's giving me back an item of type movie controller. And also, I send the movie method to the movie view. That gives me back an NSMovie, which I then send the QTMovie method to, which gives me back a QuickTime movie.
So, after all that, I can get the natural bounds of the movie, I then kick it up by 16 if the controller bar is visible, and I pass that back to whoever called me. So this is a very useful example of what do you do when AppleScript Studio doesn't have the vocabulary you need? Very easily you can go to Objective-C, add a category or other method to some existing class, and solve your problems. So let's run this now and see if it actually works. Okay, so there's my file selection dialog box. Let's try the Fire Movie. So that's sized appropriately. Let's try it again.
See if our music video comes out the right size. Bingo, no problem. Did everybody hear that? When I hit the spacebar to start the movie? I'll do it again. I'm going to turn the volume all the way down. So I'm hitting the spacebar to start the movie. What do you hear? You hear the system beat.
Or if I hit the arrow keys to advance it one frame forward, You also hear that. That's just a flat-out bug in Jaguar's implementation of NSMovieView. Basically, what's happening is the application is saying, I got a button press. Would somebody out there please handle it for me? It sends that event to the movie controller saying, I got a button press.
Would you like to handle it? As you can see, the movie controller actually does handle it. The movie does start playing, but the movie controller is clever enough not to tell whoever called it that it handled it. Then Cocoa says, nobody handled this, and its default behavior is to beep. That's just a flat-out bug in Jaguar's NSMovie that is fixed, as you will discover, in Panther. If I were running this on Panther, I wouldn't even have to talk about this problem. Let me run one more.
This time let's go for the VR movie. What's wrong with this picture? It's reversed. And again, the scrolling is bass-ackwards here. So, again, this is just a flat-out bug. This time it's... Who am I going to blame it on? Let's blame it on NSMovieView.
[Transcript missing]
So we've already seen one way in which, with AppleScript Studio, we can get access to the full QuickTime APIs.
What about REALbasic? I didn't demonstrate this, and actually I should, because there's a very useful capability of REALbasic. Let me go back to... Again, I'm just going to pull up a canned one here to save myself the embarrassment of bad typing. Looks just like before. Let's pull up our movie window. Let's look at -- let's just run it, actually. Well, let me first look at our code. Good. It's commented out. Wonderful. Let me run this.
Okay, file opening dialog box, select a movie, movie opens, movie sizes correctly. Now I'm gonna hit the spacebar again. What happened? Nothing happened. The movie didn't start. The default behavior of the QuickTime movie controller is to ignore keyboard input. Okay? So if I want that to happen here, which I probably do, I need to explicitly turn that on. So let's quit that. Let's go back to this.
How can I explicitly turn on the keyboard support for the movie controller? There's this magic function called MCDoAction, which basically says, yo, movie controller, which is the software governing the playback and the display of the movie, I want you to do something for me. We can get, using REALbasic, the movie controller identifier using this method. I'm going to send it the action 32, which I happen to know means, please turn on keyboard input.
And I'm going to pass it the value 1, which means turn it on and not off. So if it were on and I wanted it off, I could pass a 0. So I've just put that right in the middle of my REALbasic code. Can I do that? Does REALbasic understand these arbitrary functions from arbitrary libraries out there in the system? No, it doesn't, but it will if I tell it. So up here above, you can see, let me cut this out, because I don't even know that that's accurate.
I'm saying, if I'm running on Carbon, I'm going to tell you that there's this function I want to call, and it's called MCDoAction. And I need to tell REALbasic two things. I need to tell it what library that function is located in. It's located in Apple Carbon Multimedia. And then I need to tell REALbasic what the parameters are, and here I've listed them. There's a movie controller, there's an action, and then a value. And if I scroll over, it shows that it returns a value.
So once I have told REALbasic what this function is, what library it's located in, and what its parameters are, I can then call it. So let's try this. Let's try running that with our new code in there. Select a movie. I'm going to hit the spacebar, and it starts running. So with one line of code plus the declare statement, I can get access to any API in any library on my system.
Let's just check that the arrow keys are working. Wonderful. Okay, so we saw what we do with AppleScript Studio if we need to go beyond what's built in. We can declare extra methods. With REALbasic, we can declare individual API calls and use those. If we want to do something more, then we need to write a plug-in.
Why would we ever want to do something more than just call individual functions? Well, the standard mindset is that you call QuickTime, but in the Soviet Union, QuickTime calls you. That is to say, sometimes it's going to call code in my...
[Transcript missing]
Possibly you could, but if you want to do that, I think the easiest way is to write a plug-in. This is just a module, typically written in C, that you link in with your REALbasic application, and then you can call it in pretty much the same way that we called MCDoAction. The only difference being that you don't actually have to declare the function and where it is and what its parameters are if you're packaging it as a plug-in. I see I've got time, so let me show you what a plug-in looks like.
Let me not show you what a plugin looks like. Ah, here we go. Let me show you what a plugin looks like. I'm going to launch this project. This should bring up CodeWarrior. Okay, this is a CodeWarrio project. Most of this code comes straight from REALbasic's samples. The only thing I've added, there's this file externals.c, and we can see that I have defined here A number of functions, MCInitialize, MCUndo, Cut, Copy, Paste, Clear.
What this tells me is that movie controller editing, Cut, Copy, Paste, Clear, is not built into REALbasic. If it was, I wouldn't need to do this. But I can get that capability by creating this plugin that has those functions defined. So let's just take a look at one of those, mccut.
It's getting the movie controller, yada, yada, yada. It's basically calling a built-in QuickTime function MCCut. It's actually taking the movie that I cut and putting it on the scrapbook so that if I then want to paste it, I can do that. And so what I've got here is just a whole bunch of C code that I can then build.
[Transcript missing]
Thank you very much. This is a nice application. It's a full multi-window application. It's more what you think of as an application.
[Transcript missing]
Everything works fine. So if I need to go beyond what's built into REALbasic, I can either do it individually one at a time, or I can write a plug-in. Same thing with Visual Basic. Keith didn't need to do this, because here I'm showing what you might have to do in Visual Basic 6 if you wanted to size your window appropriately.
The system metric stuff is built into Visual Basic.net, but not into 6. So you may actually have to call an individual... Can we get slides back up? Okay, here we go. So this is the same syntax that we saw in REALbasic for declaring an external function, and this would tell you, for instance, how wide the frame is on the window so that you could size your window appropriately.
For RunTime Revolution, again, it doesn't have the declare functionality that I know of, but you can write a plugin similar to what we saw there that would give you additional capabilities within your application. And finally, we already saw what we needed to do with AppleScript Studio. Use this call method statement to go out and call Objective-C functions. Okay. Enhancement opportunities.
These are really good environments. I wouldn't be up here talking about them if I didn't think they were worth talking about. So each one of these four will allow you to build real-life, solid applications. Each one of them, however, has some issues that I think they could work on to make them even better.
RealBasic has what I call runtime issues. Remember when the fire wouldn't burn unless my mouse was moving around and I went and I put a timer object in the window? That's a kludge, okay? Something ought to be fixed within RealBasic so that I'm getting events more regularly. Let's launch my full featured application. Okay. Thank you. So I've launched my...let's open a file. Actually, I don't want to use this one because I fixed it in this.
[Transcript missing]
Remember we went in and we added the code that said, please enable movie controller, or enable the keyboard input so that I can use my keyboard to manipulate the movie. And we saw that it worked, right? But it only worked because I was running it inside the IDE using the debug mode. It turns out that if I take that same application and double-click it in the finder and open it up, the keyboard just won't work. So there's something gone wrong there. It's probably a very simple fix that they could implement to fix that. Amen.
Other enhancement opportunity, and this one is fairly important. So I talked about callback functions, where QuickTime is going to call code in your application. One of the most important callback functions is what's called a movie controller action filter callback procedure, just to make it even longer than it is there.
The idea being that when the movie controller does something or is about to do something, it will notify your application, giving your application the opportunity sometimes to cancel that or sometimes to enhance that. An example might be if you have a custom button in your movie controller bar. I don't have it in any of these.
Sometimes you see a little downward-pointing triangle in the movie controller bar. When somebody clicks on that, the movie controller will send you an event. Or an action saying, "The user just clicked on the button. What should I do?" At that point, you could drop down your own menu or do whatever you wanted. So these are very useful callback functions to define.
I actually went ahead and in my REALbasic plugin defined a movie controller action filter procedure to do this kind of stuff, and I quickly discovered one thing, is that REALbasic also installs a movie controller action filter procedure. And I discovered this because some of its built-in capabilities broke.
The problem being is that you only get one of these per movie controller. So when I added mine in, it basically booted REALbasics, and so I was able to get one of these per movie controller. So some of the real basics capabilities broke. There is a way around this, and basically it involves REALbasic, and we'll also see this affects RunTime Revolution. Need to come to Apple and talk about this issue and figure out how we can have several of these things running around at once.
Visual Basic enhancement opportunities, not too many there because, well, it really depends on which of these ActiveX controls you're using. Some of them are more full-featured than others. One interesting thing is that, remember I talked about the declare statement working in Visual Basic the same way it works in REALbasic.
There's only one problem, which is actually a big one. In Visual Basic 6, you cannot use the declare statement to access QuickTime APIs. That's a pretty big limitation, and it has to do with calling sequences of what Visual Basic expects and what the QuickTime library is putting out.
RunTime Revolution. Again, there's a few runtime issues we saw with the fire not quite burning correctly. I think they can get those worked out. I already mentioned it installs a movie control reaction filter procedure. Again, a fairly important issue that we need to work out between them and Apple.
AppleScript Studio enhancement opportunities. Fairly limited vocabulary right now for handling movies. There's only about 13 properties that with pure AppleScript I can get in set. We saw that it was fairly easy to work around that limitation, but it would be nicer if more and more properties were available natively.
Another opportunity for them to do some work, which is both good and bad, AppleScript Studio applications are Cocoa applications, so they inherit any features of Cocoa classes, but as we saw, they also inherit any bugs from Cocoa classes, and we saw two of those that have been fixed, thankfully.
Okay, most of this I've already talked about. For those development environments that install a MovieControllerActionFilter procedure, they need to get together with Apple and figure out how to work around that problem. One interesting thing is I'm begging them to please, when you open a file, open it with read-write permissions. Your development environment may not support editing, so you may not think that you need to open it with write permission.
But if I'm a clever programmer, I can write a plugin to support editing. But I've got this edited movie, what do I do with it? I'm all dressed up and I've got nowhere to go. I can't put it back into the original file if that file has been opened with read-only permission. REALbasic, of course, opening it as an edible file, opens it with read-write permissions. RunTime Revolution opens files with read-only permission. So once I've written my plugin to edit this movie nicely, again, I've got nothing to do with it other than to put it into some other file.
The Skylight ActiveX control is kind of a funny case because it's got built in all these editing methods, but it opens the movie file with read permission. So why is it giving me all these methods if I can't save it into the file? Finally, and most of the people do this, although again, interestingly enough, Skylight does not, make sure that there's a way that I can get the movie and movie controller identifiers so that within my plug-in, I can take advantage of that.
Okay, now for some boilerplate. Here's some contact information for Real Software and RunTime Revolution. I should mention we have representatives from both of these companies in the audience today, so afterwards maybe they could come up to the front here, and if you have specific questions for them, that would be wonderful. Here's contact information for the ActiveX stuff.
The AppleScript Studio stuff. And finally, if this was not enough detail for you, there's been a very nice series of magazine articles in Mac Tech Magazine starting last December and extending out into the future discussing these various environments. So if you want the gory, gory details, I highly recommend picking up these magazines.
And there's some documentation on QuickTime, not generally relevant to what I just talked about. and today ongoing for the rest of the day are the QuickTime labs downstairs in the Sacramento room. If you want to sit down and talk to some QuickTime engineers or some really good content creation people, I highly recommend you stop down there. and there's me, Keith Guillermo. And we have a little bit of time to take questions.