Configure player

Close

WWDC Index does not host video files

If you have access to video files, you can configure a URL pattern to be used in a video player.

URL pattern

preview

Use any of these variables in your URL pattern, the pattern is stored in your browsers' local storage.

$id
ID of session: wwdc2004-214
$eventId
ID of event: wwdc2004
$eventContentId
ID of session without event part: 214
$eventShortId
Shortened ID of event: wwdc04
$year
Year of session: 2004
$extension
Extension of original filename: mov
$filenameAlmostEvery
Filename from "(Almost) Every..." gist: ...

WWDC04 • Session 214

Programming QuickTime with Cocoa

Graphics • 1:12:23

Learn of the capabilities that make it simple and natural to work with QuickTime in the Cocoa environment. If you use QuickTime in your Cocoa applications or would like to enhance your products with QuickTime's multimedia capabilities, view this session to learn all about the new Cocoa developments from the QuickTime engineering team.

Speakers: Ian Ritchie, Tim Monroe, Tom Maremaa, Kevin Calhoun, Adrian Baerlocher, Michael Johnson

Unlisted on Apple Developer site

Transcript

This transcript was generated using Whisper, it may have transcription errors.

Well, welcome to the session. My name's Ian Ritchie. I've had the opportunity of managing part of the QuickTime Engineering team this last year, actually for a number of years. We decided to-- in fact, some of you were here last year, and we mentioned that we're working on a new set of Cocoa classes for a quick time.

We listened to your concerns. We heard NSMovie and NSMovieView had some issues you wanted us to take care of. We said, well, how are we going to do this? Because we're QuickTime engineers. We know QuickTime inside and out. We didn't know a lot about Cocoa. So we actually-- the whole team took Cocoa classes. And we met with the Cocoa development team, Oli Ozer and Andrew Platzer and others. And a lot of direction from even executive management on how to work on these classes. And we'll explain today what we've come up with. You're gonna learn about the new APIs that we offer.

Tim Munro will come up and talk about the classes. We'll show you some sample code that we worked on. Like what could you get working on today? Just after a few minutes, you have it on your DVD. And then we'll go into what if you had a few days to work with this? Some things we came up with these last few days after we finished working on the seed for your-- DVD that you have. And then we have a special guest at the end of this.

The old classes, NSMovie, NSMovieView, when we tried to use these, just like real fast, you ran right into Carbon. And you go, oh no, I've got to idle a movie? Well, I don't know about that. And what's a handle? You know, since Mac OS 9, most people don't know these or aren't used to using these structures and data types. So you ran into limitations that we decided to address. And of course, there were an occasional bug or two in the old classes.

So you've probably heard Apple explain, we're committed to Cocoa. We want you to use Cocoa. If you're going to develop an application on OS X, use Cocoa. And they mean it. We develop an application on both OS X and Windows, the QuickTime player. And we are committed to developing the QuickTime player for OS X in Cocoa. I'll explain in a minute how we did that. We developed a QuickTime broadcaster. A lot of the iApps that you see-- iPhoto, iMovie, other apps we have at Apple-- are using Cocoa. So we encourage you all to embrace this technology. And Apple is committed to providing access to other parts of the OS in Cocoa classes.

We looked at it as a Cocoa programmer would. We removed all the carbonisms. So you can get up and get running in no time with your Cocoa background. This next, well, where possible, we adopted the Cocoa model. There's a few places that we'll tell you about that we made exceptions. And we also provided a new palette to Tim Monroe will go through in a little bit that will show you the new functionality. So on the abstraction, we have to deliver QuickTime virtually everywhere.

90%, 95% of our users are on Windows. So when you're developing an application, we said, well, where do we put the code? Where do we put most of it? We push it down into QuickTime as much as possible. And then above this, we have-- two layers. We have an ActiveX layer and we have a Cocoa layer. And these -- one of the layers here today that we're going to talk about is the Cocoa layer.

That's what we built the player up on, both for Windows and Mac. So your application should be relatively quick-time agnostic and just use the classes and be able to get up and running in no time. I'd like to introduce now -- I even wrote some of these things down -- one of the Apple premier multimedia This is all in print. You can look it up on the internet. He is the resonant QuickTime guru in many circles, an author extraordinaire. You've seen many of his articles in Mac Tech. And he's also written the QuickTime Toolkit, Volume 1 and 2. I encourage you to run out and get this book. Let's bring him up now here. Tim Monroe, he is also the tech lead of the QuickTime Cocoa Kit. Come on up, Tim.

Thank you, Ian. What I want to talk about here is briefly go through the kit, give you an overview of what classes are in it, and then I want to do a real quick demo that shows how to use the kit, and then I want to get out of the way so that the really fun demos can come forward. So there are five classes in the QuickTime for Cocoa kit, and there are two data structures.

So let me start down toward the bottom with the data structures because we'll need those when we get to the classes. We are providing a data structure called QT time that is going to be our preferred method for indicating a time or a duration in a QuickTime movie. And you can see there's three fields here, a time value, and the time value is interpreted relative to the time scale, which is the number of time units per second. And finally, we've added a flags field here, and this allows us to do some interesting things like indicate that a time that we're passing back to you is not really a valid time or is perhaps an indefinite time. This might happen, for instance, if you ask for the duration of a streaming movie, it doesn't really have a duration, so we might pass you back the flag that it's indefinite. You can see the QT time is indefinite flag there.

So we have a bunch of utilities for creating QT time structures, for adding them together, for comparing them. We've tried to do everything as much as possible in the Cocoa flavor. And there are two predefined QT time structures that you'll be working with, namely QT zero time, which is a zero time or duration with a non-zero time scale. And then the QT indefinite time, which has that flag, that bit set in the flag.

If you take two QT time structures, try that fast, and put them together, you have a QT time range. And that indicates a start time of the range and the duration of the range. And once again, we have a number of utility functions that you can use to operate on time ranges. For instance, QT time in time range will give you back a Boolean value. And finally, we have added categories on the NSCoder class that allow you to encode or decode QT time ranges and QT time structs. So when you archive or unarchive objects, you can add these items in. Thank you.

So let's get to the classes now. The main class you'll want to work with is QtMovie. This represents a QtMovie and movie controller. We don't see any use in separating those two items into separate classes. There are quite a number of ways to create a QtMovie instance. I've got some of them listed here. If you have a movie in a file, you can give us the file name. If you have a URL, we'll take that.

If you have a QtDataReference, which I'll talk about in a second, we can initialize a QtMovie object from that. NSData, or finally, if you want to put a QuickTime movie in your nib, we also have this method MovieNamed, which you may recognize as similar to the ImageNamed method for reading the movie out of your nib file.

So once you've got a Qt movie object, we have a large number of methods that you can use to navigate within the movie or to get movie attributes. Let me just talk about the attributes for a second. There's a few methods that will give you a specific attribute directly. For instance, the current time method will give you back a QT time structure, which represents the current time.

Now, we could have defined methods for all the very many attributes that you might want to get, but we haven't done that. What we will give you is an NSDictionary that contains key value pairs of a large number of keys and the associated values. Thank you. If you just want one particular attribute, then there is a method, movieAttributeForKey, so you can pass a specific key and we'll give you back the associated value.

So if you have a movie, you can also get an array of tracks in that movie. And finally, if you need to go underneath the kit, if there's something the QtKit doesn't do, and you really like working with those Carbon APIs, you can get the movie or the movie controller identifier and use that in your code.

The next class we're talking about is QT track. As you know, a QuickTime movie is composed of tracks, so we will give you back, if you wanted, a list of tracks of QT track objects in the movie. Now, there's only one way for you to create a QT track object yourself, and that's if you already have a QuickTime track, you can initialize a QT track object from that existing QuickTime track.

The way that you get and set track attributes is exactly parallel with the way that you do it with movie attributes. Finally, you can get the media object that's associated with the track. And also, in the case that you need to go underneath the kit and work directly with the QuickTime track, you can get that track identifier.

Not much to say about media. Each QT track has one media associated with it. Again, if you want to create a media, there's only one way to do that, which is to start with an existing QuickTime media and call it the initWithQuickTimeMedia method. Media attributes works just the same way as movie and track attributes. You can get the track associated with the media. And finally, if you need to go underneath the kit, you can get the media identifier. are.

There's a QtDataReference class, which I don't want to say much about because we'll talk about it a bit later, but the standard way of talking about, of referring to data in a movie is with a data reference. So we'll talk more about this later. And finally, the view object that we'll be working with is QtMovieView. It's a subclass of NSView that is associated with a particular QtMovie object.

I've listed some of the attributes that you can get and set. We'll look at this more in a second when we get to Interface Builder. And finally, there's a large number of IB actions that you can wire up to menus or buttons in your interface. So that's really the kit. They have asked us to mention a few issues that you will run into if you start working with the version of the kit that's on your DVD.

And I've listed three of them here. There are some cosmetic drawing issues that you'll run into that you won't see here today because we have a fixed version of it. Currently, you cannot usefully subclass a Qt Movie View and get the event handling to work just right. And finally, I would not recommend trying to rotate a Qt Movie View right now. So let's go to a demo with this.

And I'm going to show you with six lines of code just how easy it is to write a multi-document QuickTime display and editing application. So let me launch Xcode here, and I'm gonna ask for a new project. And I want a new project that is a Cocoa document-based application. Let's call this demo.

Tell me you're crashing. There we go. I'm a pessimist. Let me open the.h file, and I'm gonna need one instance variable here. Actually, first I need to do this. When I'm using the kit, I need to, of course, include QtKit.h. And then I'm gonna wanna have one instance variable here. I want a QtKit.h. Come on, movie view. And let's call that movie view.

This will work. So let's save that. That's all I need to add to my.h file. Let's go into the.m file. And so I'm going to be loading Windows from nib files. So I want to come down to the window controller didLoadNib method and add a few lines of code. So in the instance that I'm loading a movie from a file, so if, self file name is not nil, I want to do something, and that is to create a Qt movie. And let's call that movie. And how am I gonna create that? I'm gonna call the class method QtMovie, movie from file. And what file? Self file name.

And if I get a movie, I'm just being careful here, I want to assign that movie to the movie view which is going to be loaded. So I will say movie view, set movie to movie, and I believe I'm done with my code. So let's save that. Now I need to set a few things in my target here. First thing I wanna do is when I'm building, oh goodness, I don't want to do the precompile, the prefix header, 'cause that'll take too long. And finally, I want to set my document type so that when the open file dialog comes up, I can open MOV files, And that's all I need there. I could add in other document types here, but I'll refrain from that. So let's see if I can build this.

Build succeeded, most excellent. But I'm not quite done yet, 'cause I need to set up my user interface. So let me open the document nib. I'm gonna get rid of that text thing. And the first thing I wanna do is resize my window. You'll notice that I didn't put any code into my source file that resizes the window to fit the movie. So I'm going to set this... I'm going to set the size of the window to a known size that will fit my movies.

Okay, and now I want to drag a movie view object into my window. Set it down here. I want to set its size to resize to fit the movie window when I resize it. And now let's set a few attributes on the movie view. You can see I can show or hide the controller. I'll show it. And I want to make this editable. And I need to do one last thing. I need to set up an outlet for the file owner. So I'll come in here and add an outlet and we need to call that movie view.

Now let's come over here and wire it up. I will Ctrl+click, make the connection. save that, and if the demo gods are smiling on me, I can go ahead and run this. And demo is running and there is an, So let's now go over here to the open file and open a movie file.

Very good, thank you. One thing you cannot forget to do is add the QtKit framework to your project. or it won't run, so we're gonna go to system library. Frameworks, look down here for the Qt Kit framework, add that to our project. Yes, now let's build and run. And now things are working fine.

So I can open, let's open that one that I tried to open before. Movie from file. Ah, thank you. It's not movie from file. You'd think I'd know this stuff now. It's movie with file. Okay. Now that we've got that... Let's try running this. Oh, I'm still running it there.

There we go. Now this should work. Let's cross our fingers. Open that. Bingo, we've got it. This is actually a flash file. One thing, let me show you real quickly. In the keynote on Monday, I showed you that there's a contextual menu for movies. And if I control click in this, this is a flash movie. I actually get items here that are relevant to flash. So I can zoom in, zoom out and so forth.

All right, let me very briefly show you one more thing. And this is to show you that the kit provides you a large number of behaviors for free. Okay, so I've opened three movies here. I have two VR panoramas, and let me line this up just right. So this is Donner Lake in the winter and Donner Lake in the summer. And, oh, that's exciting. So let me try opening that again.

So something is missing here. What I had was a wired sprite movie that sent messages to the two panoramas to tell them to pan. So I can't do that here because the movie isn't opening correctly. But that illustrated one thing that you get for free with the kit, which is automatic intermovie communication. So with that bumbling through, let me bring up Tom Merrimah, and he will discuss what you can do, hopefully with more success, if you've got an afternoon to play with the kit. All right, Tim. Where is the clicker? Is this it?

forward on this. I'm Tom Maremaa. I write technical documentation for Apple. I've been working with a QuickTime team for the last seven years, and this is just awesome stuff. I decided to see what I could cook up with the framework basically in an afternoon. Whoops, that was too fast.

How about going back here? And I wanted to basically build a little QuickTime kit media player app in Tiger, something that was tasty, easy to cook up, and wouldn't burn my fingers. I basically wanted to do an app that could play, display QuickTime movies, import/export, and also do some editing beyond simple copy and paste. And this would involve maybe a couple hundred lines of code. So what did I need? Well, first of all, Tiger Cookbooks. Yes, we have some Tiger Cookbooks to work with a QuickTime kit framework.

Second thing is sample code, which you can download, which is a piece of cake, and then some basic Cocoa programming. Third thing, ingredients. Start with Xcode, obviously. Make sure Panther or Tiger is installed. And the key is add QuickTime 6.6. And then we're going to bake it up with the new classes. When completed, invite friends over to watch and enjoy my PlayRap doing its thing.

Finally, all the documentation, the reference, and the programming guide is available, plus the sample code that I used to build this app. Notice that... we have not included the 3,300 pages that are part of the procedural C API. You won't need that. Nor will you need the thousands of other pages that we've written over the last 10 years documenting this awesome QuickTime technology. So can I go to the demo, please? Whoops, that's going. Okay. I'm going to just close. I think this is Tim's stuff.

around a little bit. This is my QtKit player app, and as you can see, I have added my QtKit framework, which is what Tim was showing. This is basically an app that was cooked up in a couple of days. And what I want to show you is just a few features that are unique to it. I also use the QtKit palette and was able to drag. Here's my Qt movie view. And from here, what-- I'm going to do is show you what you can do as far as adding some of the actions. As you can see, I have specified my fill color as blue. I'm showing my controller, and I'm not gonna be showing the editing part yet. Let me just go back to this, and I wanna show you what I've wired up here.

Hey, this is the cool stuff that comes with the kit. As you can see, I can add, add scale in addition to the cut, copy, and delete. I can specify my actions to go to the beginning, to the end. I can replace. I can start backward, et cetera. Then from here, let me just pop open real quickly. Thank you.

the main menu nib. I don't know if you guys can see this, it's getting a little bit crowded here. I should probably, and here I've added importing plus an export view object. I've added some of my other menu items in my edit menu and also in my movie. So from there, Let me just close this down a little bit. I don't want to save anything.

Let's see if anything. Now, here's the good stuff. In my declarations, they're all very straightforward. I think this is standard Cocoa stuff. You can see what we're doing as far as the class methods, the inits, some of the setters. This is probably the most commonly used of our methods. in the QT kit, and down here, here are all of our IV actions.

things get a little bit more complicated in the implementation file. This puppy is somewhat longer. As you can see here, I have a pound defined that specifies the width of my movie at 320. This is primarily to open up audio movies. And this code, this sample code is all available for download and it's all documented block by block. The interesting parts, I think, have to do with, and I think Kevin Calhoun will talk a little bit more about some of the issues involving sizing. Here we're opening up our document with the contents of the file, and this is partly where we're going to be doing some of our importing.

The beauty of working with the Qt kit, I think, is that it doesn't take a lot of code and it really dances for you. So I'm going to just quickly build and run this puppy. And there's my QtKit player app. As you can see, this is the default. Now, here's where it gets a little bit interesting. I can basically import, and I have control.

if we get some sound. Do we have sound? We don't have sound on this machine? Okay, the next item that I want to import for you guys is my MPEG-4 file. Now here we've got... you've got some control over movie playback. Hopefully you don't have to cook with cockroaches like that.

And guess what we've added? We have the capability, which I don't have time to demo now, of additional editing functions. Add, add scale, replace and trim. We can toggle the controller. And if we want, we can even clone it. There we are. Okay. Things get pretty hot. We can even import JPEGs, still images, And my favorite import item, being a guy who does documentation, I decided to actually import a PDF of the documentation, which for you guys, and it has a scroller down here, for if you guys can read it 30 frames a second, there you are. Okay. Happy cooking. Thank you.

So the document is available that you just saw now. Since you read it so quickly, you don't need to pick it up off of your seat. But for others at the conference, you might point out to them that the QuickTime Kit Reference for Objective-C and the QuickTime Kit Programming Guide are available. Thank you.

I'm Kevin Calhoun. I'm still a software engineer at Apple Computer. And I'm going to talk to you about some more advanced scenarios once you get involved programming with the Qt kit. You are going to have needs that go beyond the things that you can do in a morning or an afternoon. You might have to work into the evening. These are the nighttime topics. Let me go through them one at a time for you.

As Tom mentioned, there will be some code that's necessary if you want, when your Windows nib is loaded, if you want to size a view or size the entire window to fit the natural size of a movie. But we've made this easy for you. It's possible by means of one of the methods that Tim mentioned earlier, the QtMovie attribute method, to find out what the natural size of the movie is. Then you can use that size to set the size of your view or your window accordingly. You can check whether the movie is displaying the movie controller and add in the size of the movie controller if it is. Thank you. And that code, in fact, code that looks exactly like this, is in Tom's sample application, which we have distributed to you. So you can see it in action.

Tom's application, you call that the QtKit player, is capable of opening any of the media formats that QuickTime is capable of opening. And it does this merely by calling the method QtMovie, movie with file. That's all you have to do, and you can open MPEG-4, all the still image formats that QuickTime supports, AVI, a whole range of formats, even QuickTime movie files.

But you might want to tell NSPanel or NSOpenPanel when you bring it up that you want it actually to make all of those different file types selectable. There are two ways to do that. This is one of them here. You can use the class method on Qt Movie, canInitWithFile, in order to determine whether a file should be selectable in NSOpenPanel. You do it just like this. You set yourself as a delegate for the panel and you handle the method panel should show show file name. And you can respond, should I show this file, by calling can init with file. The other thing that you can do is you can actually get from Qt movie, there's a class method that will return an array of all of the file types that QuickTime can open if that's what you need to do. It's really a tradeoff. If you have a small number of files, you might want to pass them for a filter like this. If you have a wide range of file types, it might be more efficient for you actually to get that whole array.

Okay, other topics. We showed you opening movies from files. We mentioned that you can open movies from URLs. Well, what happens if you have media data stored in an instance of NSData? I've got NSData sitting around and I've got AVI in it or I've got MPEG-4 in it. I want to make a Qt movie out of that.

Well, that's very, very easy. There's a class method on Qt movie, movie with data, but I wanted to show you just a little under the hood what that method actually does. It initializes -- well, it creates an instance of QT data reference that essentially refers to your NSData as the source of the media that the movie will be able to play and manipulate. When you do this, it's very handy if you give QuickTime a clue about the format of the data in your instance of NSData. There are two forms of clue that we're able to read. One is a file name with a path extension. If it ends in.mov or.mp4, that's a good clue about the format of the data that's in the NSData. Or you can give us a MIME type, and that will help us determine how to import that data in your NSData. And then you can manipulate media data in instances of NSData using the very same methods that you saw demonstrated in use with files.

OK, that's media data coming into the kit. What about going out? You have a lot of options for storing your movies in files and for re-encoding your movies into other forms of media. Option one, you can simply write your movie out to a QuickTime movie file. a file which only stores a reference to the media data which is stored externally. That's easily accomplished via the Qt Movie instance method, write to file with attributes.

The second option is perhaps you want to save your movie after you've performed all the manipulations on it that you want to perform out to a QuickTime movie file, but you want to store a complete copy of all the media that that movie requires. That's easily accomplished by means of the Qt movie method write to file with attributes.

I've achieved a theme for my talk. I'm satisfied. I can move on. But in this case, you have to put in that NSDictionary that you pass for with attributes some information that tells the Qt kit that you want to flatten. You want to copy all the media data to the output movie file. So that's what this code accomplishes.

Of course, if what you want to do is to store your model by means of NSArchiver, you can use that with QtMovie instances as well. You can archive the movie as part of your whole object hierarchy. Finally, the last option is you can just get, in an instance of NSData, the serialized freeze-dried form of a QuickTime movie using the method movie format representation. Once you have that, you can store it anywhere you like. In instance of NSData, which you can write to a file or do whatever you need to do with Finally, if what you want to do is not store your movie, but re-encode it or export it or somehow turn the media that that movie plays or represents into another format, how do you do that? Well, you can simply use the method write to file with attributes. Some of the attributes that we support tell us what kind of container format do you want to store it? In other words, what QuickTime movie exporter do you want to process the media and store it in that container format? You can tell us you want AVI, you can tell us you want AIFF, what have you. And furthermore, you can tell us what compression settings that you want to apply to the audio and the video as your media is recompressed and stored in that container format. Now, this particular snippet of code, the longest one that I'll show you today, shows you that you can load some presets from a plist that you store inside of your application bundle that contain those export settings that I mentioned. The question is, where do you get those export settings from that you might want to store in a plist? Well, I wrote a little sample app that does exactly what you would need to do. So let me come on over to the demo machine.

We have a left-handed demo machine today. And I wrote a very simple application that really does one thing only. It manages a list of export settings. And it saves them to a P list of exactly the form that I mentioned in that code snippet here. This is a very simple Cocoa app. All that it does is show you an array of export settings, such as high quality or digital video. And for each of these presets that I want to use in my application, I can edit those export presets. Let's see, I want high quality to use the video compressor-- oh, let's see, what do I want to use? What do you want to use, Michael? Pixlet.

and I want that to be high quality, and I like 30 frames per second. And I want my sound to be stored as... Apple lossless at 48 kilohertz, because I know that's the audio format that I'm going to be working with. And I'm not interested in preparing for internet streaming, because I'm just using this in my production pipeline. But if I'm delivering to CD-ROM, perhaps I want a different set of settings.

I may want to encode my video to MPEG-4 with medium quality. And I want my audio, in this particular case, to go to MPEG-4 audio. AAC. Looks good. And so all I'm doing in this application is editing and saving these presets. I set my high quality to be Apple Pixlet Video and Apple Lossless Audio, and I set my CD-ROM preset to be MPEG-4 Video and MPEG-4 Audio. Now I can save... this collection of presets to a document. I'm going to say, these are my export settings. And I'm going to store them out on the desktop.

And what I actually save in this application is a plist. And inside of that plist, which has the file type-- if only you could see the file type-- .exportSettings, it's a simple plist that contains those export settings that I can load in my application later on and apply to an export operation. This is sample code that we'll distribute to you if you want to implement something, for example, like iMovie. If I can come back over to slides, please. If you have something like iMovie that has a panel that says export to web, export to CD-ROM, this is exactly how you can implement that in your own applications. Finally, my last scenario of interest. When you're dealing with media, the interesting thing about media is that it can come from many places and have a variety of characteristics. One characteristic is that it can be slow. It can be coming from remotely over a network or it can be a media format that QuickTime supports that might take us a while to scan in order to apply all these great features for it. For example, if it's primarily a streaming format but you want to do editing on it, QuickTime might have to do a little bit of work to prepare it for that. What you need to do in your applications is to check the load state of Qt movies to determine whether or not they're ready for the operation that you want to perform. Check to see if the load state is complete before you perform editing or saving operations. We're making this easy for you by giving you the movie attribute, the Qt movie load state that you can check for this. And our own operations, for example, if you call write to file with attributes to do export, will do the checking for you. But it's something to be aware of. Okay, so those are my higher level scenarios of interests. I'm going to turn the stage over to Adrian Baerlocher, who's going to show you some of the cool things that he built. I'm not sure if he did it in the middle of the night or when, but he'll tell you. Thank you. So can we switch to the demo machine, please? I'm going to show a couple of very simple demos using QtKit in Tiger.

So the first demo I have is a movie screensaver. So Tiger OS X has a screensaver framework for writing your own screensavers, and you basically just return a screensaver view. So in this case, we want to use a Qt movie view. So programmatically, we can create a Qt movie view and add it as a subview to our screensaver view. And in this case, we set some attributes of the view, too, to hide the controller and preserve the aspect ratio. So this is only about 200 lines of code or so. Most of this actually involves setting up a configuration sheet in this case. The only other thing I wanted to show here was the... Oh, yeah, so we also observe a notification. There's about 16 different notifications on Qt Movie. And in this case, we observed the Qt Movie did end notification so that we can know when the movie finishes and go on to the next one. So most of these notifications are useful if you want to customize your user interface.

So you should see here, we have a little preview like other screensavers. And this is just picking up movies from the movies folder. And we can select which ones we wanna put in here and loop them or mute them. And we can, of course, test. This would go on to the next movie once this one would finish. So it's a really simple example. The other example I have here is of a movie plug-in.

New in Safari, sorry, in Tiger, WebKit has exposed the Akoko plugin API. And it's actually very easy to write your own plugins for WebKit. And so there's a method you provide, a class method plugin view with arguments, and we get a dictionary. This is just a dictionary of the attributes you get from the embed tag in HTML. And so I use those to initialize our Qt movie view subclass plugin movie view and also create the movie and set that on the view. So our subclass in this case Also, so this is the plugin.

So in this case, we return self, the plug-in movie view itself for the object for the WebScript object. So it's also very easy to add JavaScript support. And you just need to implement these two methods, isSelectorExcluded from WebScript and WebScriptNameForSelector. And this is just mapping the Cocoa selectors to the JavaScript function names themselves.

And you can see I have, like, play, stop, stepping, and go to end, and full screen. And most of these just map to Qt Movie View, so I can just call super for these, except for full screen. But it's actually very easy to do full screen in Cocoa. I mean, we can just create a window, set the level to around screensaver level, set the background color, and add our Qt Movie View to the Windows content view. So let's just run this. Thank you. So not the greatest UI, but all of these buttons, these are all JavaScript on the plugin. They're coming for me.

  • Let's bring it closer.
  • This will be the greatest of the world has ever seen. We need the-
  • And we can step and I'm sure you can think of much more interesting things to do. So these are just a couple of very simple examples of what you can do using QtKit. I'm sure you guys can come up with much more interesting things. Thanks.

We're here. Well, you've seen a few of the things we've done recently with the Cocoa classes and QuickTime. You've been to some of the other QuickTime sessions, I hope, and if not, a lot of new exciting technology is in this next version of QuickTime. And the Cocoa developers that embrace the kit, the QuickTime kit, will get a lot of these technologies for free. We're going to continue to develop the classes going forward. And there's a lot of functionality now that's in the kit today. So adopt them, put them in your app, and we'll do the hard work and the heavy lifting for you. You have the rest of the QuickTime team behind you. OK, thanks for coming. That's our show. Oh, wait. One more thing. There is one man that is more responsible for what we've accomplished here. the instigator, I guess, the man behind the throne, and also our number one QA person, because from early days, he was encouraging the QuickTime team and Apple to get behind the Cocoa effort and has adopted the kit from early on and helped with the design and guideline. And I'm very proud to have him here. And you're in for a treat. It's Dr. Michael Johnson of Pixar. Let's bring him up.

I like you Ian, that was way too nice. Now I owe him money again. Well, yeah, so just to start off, I'm in a group called MPG. Every year I come, I'm in a different group. So eventually they're going to get rid of me, but they haven't yet. So people were asking me what MPG was. It's actually the Moving Pictures Group, but, you know, the various jokes are your mileage may vary. We move the pictures so you don't have to. There's no experts here, or the expert is silent. And other people at Pixar think of us as the media pipeline group. And really, we're the people who are responsible for a chunk of, in the Studio Tools group, the apps, technology, and workflow for kind of what I think of as film development. And that's really... kind of development, it's sort of trying to come up with the movie, the story department, the editorial department, the layout departments. And these are the groups that really deal with the film as a large-scale entity. And a lot of the other groups at Pixar and the production pipeline are dealing with a shot or a model. And so we actually deal with sort larger chunks. And so one app that some of you may have seen that we wrote back about three years ago is this thing called Pitch Doctor, which we use in the story department. And another one which some of you have also seen is this thing we call Review Sketch, which lets our directors actually draw on top of any of the footage that they're seeing in the screening rooms. And for the last year or so, we've been working on this thing we we were calling the, or still are calling, the Film Online Kit. And it really would not have been possible without this effort by all these amazing engineers in the QuickTime group. And it was something that I wanted to do because a couple years ago, my view of QuickTime was, QuickTime, it's too big, it's hard, it's crufty, and it's fragile in the sense that I had to know to call this and then that and then have this thing initialized or whatever. And QuickTime's APIs, they make me tired. And if you're a Cocoa programmer, and actually that's, so let's take a little survey here. How many of you would consider yourself Cocoa programmers who want to learn something about QuickTime today? Interesting. How many of you would consider yourselves kind of quick time people or sort of old school Carbon people and you're trying to learn more about Cocoa this time?

Okay. Yeah, it's about the mix, I figured. So, but see, that's the thing. It's like, for those of you, you know, the second group there, I really, really, really, really want what QuickTime can do for me. Like, you know, I don't want to do this stuff myself. And, you know, because my group at Pixar, you know, we're a pretty small group, relatively speaking, and we're all about leverage. And QuickTime is all about leverage. And so I had an idea.

So, now here it is, you know, from 2002, then a year on, I had a different view because they'd come to me and they'd say, you know, we're working on that thing and want to do it, and like, what do you need out of this thing? Because here's what we're doing. And so I said, you know, well, actually pretty simple needs, you know, QuickTime is this enormous, enormous thing. So I want, you know, a model level class for a QuickTime movie. pretty straightforward, it seems. I want a really nice view level class for a QuickTime movie. What do I mean by nice? Well, the first obvious thing is maintain the aspect ratio.

It drives me nuts. You work on a film, you can't, no, I got the bars, don't mess with the... Yeah. Then this was the thing that I think may have thrown them a little bit But I also think that it's kind of the obvious thing, and I don't know if this is from, because I work at a place like Pixar where we make cartoons, or if it's because I'm a Cocoa guy. But I wanted to easily and quickly make movies of movies. And there's a bunch of other stuff I wanted as well. But just sort of movies of movies, you say. What would this be? And so this was actually one of the things that fundamentally appealed to me about QuickTime was that if you looked at any of these other media formats, and I don't even know what that means, but ways that you could imagine storing synchronized audio and video. Way back when, I was at a place called the Media Lab at MIT a long time ago, and we did stuff early on with QuickTime. And I remember very early on hearing somebody talking about the fact that you could make a movie that had other movies in it. And I was like, well, of course, that's the obvious right thing. And so that's always stuck in my head. And so for us, what that means is when I think of a movie, I literally think of a movie that we're working on. And that's Acts 1, 2, and 3. A given act has a bunch of sequences in it. A sequence has a bunch of shots. A shot has a bunch of frames.

And then those frames all have some set of layers on there. So I went to Ian and Kevin, actually, and said this is sort of what I wanted. And Kevin, God bless him, gave me like a bunch of code that I did not understand. And it did exactly what I wanted. And every time I would say, you know, I would send him some mail and I would say, Kevin, you know, you old school carbon-y QuickTime guy, you know, what I really wanted was I wanted to be able to do this thing with this in and out point. And he's like, yeah, Michael, it's in the code. Just use the code that I gave you. And so, you know, but it was a lot of code. And so I got confused easily. So eventually, I finally learned enough about QuickTime to be able to ask the right questions and figure out how to actually implement this stuff myself in the kit. And I like to think that those discussions had some influence on the API to make the kinds of things that I wanted to do much simpler for you guys. Now, one of the things that will sort of come up in this is, you know, is this stuff fast enough? And I sort of have measures of what's fast enough.

And so for me, it's does it get me the leverage I need? And it absolutely does. And it's always, you know, it's the old, well, no, it is. It's magic. This stuff works at all to me. I just remember a line from Alan Kay back a long time ago, and he had some harsh words for the Macintosh, and somebody was like, you know, why are you harshing on the Mac? He said, oh, well, it was the first personal computer, you know, worth insulting. And so this is like, this is what I feel like with the kit. It's like I finally am at the point now where I can have a conversation about QuickTime and actually say something, give some useful critical feedback because now it's finally good enough in the sense of like that I can actually do something real with it. So this is, I'm going to toss this up and I'm going to talk about it a little bit now. And then I'm going to give a bunch of random demos. knows. But this is pretty much the code that's like at the core little thing that I asked Kevin for a while ago. And the idea was here is I have a little thing in my Film Online kit, the FOL kit. There's a little thing called an FOL element. And an FOL element basically just has a movie in it and it has an in and out point and it has some other little bits and pieces of information in there. But the idea was is you'd have an FOL element and then you'd have an FOL sequence and that would be a subclass off of it. So an FOL sequence ordered list of FOL elements. And the idea there was so you could have movies of movies of movies. And I didn't want it just to have it be -- I wanted it to be as thin as possible layer on top of the kit, but I wanted it to be a layer. I didn't want to just, you know, try and convince Apple to basically, you know, write it for me. I've done that before.

I think you guys have that codec. And so this is all it really came down to. And what's What's cool about this is that you can do the whole thing with QT time, which is a wonderful, wonderful little struct. Again, it goes back to the core getting it right with QuickTime thing, the fact that QuickTime has always thought about time correctly, and they always thought about it as a value with reference to a scale. Jim, hats off. What's going on here is basically I'm grabbing the movie out of this sequence that I'm in and I'm grabbing the movie that I want to stick in there and I find the time that I want to move the thing into there and then I call this method, this insert segment of movie time range at time and magic happens.

Some other things to think about, and I'm going to give you a bunch of demos here, but I want to put a bunch of ideas in your head when you get your hands on this stuff. One of the cool ones is we worked with the Final Cut folks to come up with, I mean they did all the heavy lifting, we gave them one good idea, on this xMeml format. I've got the URL here, I went and checked that last night to make sure that was the live link there. It's a great file format, and what's cool about this is especially if you're like me and you're building things on top of the QuickTime kit, and QuickTime is a great file format, don't get me wrong, but there's a lot of times you're going to want stuff to basically be editable somewhere else, especially if you're like me and you own a teeny part of a very large production pipeline and you need to have things flow around there. This XMML format is really great for that, and in our kit we actually support we can read and write it, and so that means you can sort of put these things together and then you can save them out and just double click, open them up in Final Cut and it just works. Another thing that I've been sort of thinking about as I've been here, I mean the command line apps is a big thing also for us and what's cool about the kit is, so again I've been trying to learn QuickTime for years, okay, failing miserably for the most part until this stuff came along. And one of the things that sort of always comes up is people wanting to make reference movies, right? You've got like these five movies and you'd like to make a movie. Here's my movies with movies theme again. I guess there's this guy Peter Hottie and he wrote this thing a million years ago and people all go and get this and oh it's over here, oh it runs in classic. There's some little thing for doing this stuff and I'm sure all the QuickTime gurus are going, "Well no Michael, you just do this." As far as I could ever tell, it was just sort of black magic. You can write this in like three lines now with the kit. That's just so killer.

You can basically open up a movie, insert movie of movie into that movie as you iterate over your movies, and then save the thing out again. Now you can even transcode it to a different codec if you want. Amazing. Also, I was just thinking when I went to that Automator talk the other day about the fact that if you think about these things as little command line apps, you can imagine doing all sorts of really neat things with QuickTime movies. Anyway, the other thing that you may want to do is you may want to put whatever stuff you do on the kit on an IB palette. And that's what we did. So we have this idea of what we call a sequence provider. And a sequence provider is basically a model object that is holding on to -- it's basically fronting for one of these sequences.

It's basically providing that thing for you through a model control layer. And we have a set of formal protocols that these sequence providers conform to. So there is the notion of an FOL sequence providing, there's an FOL mutable sequence providing, an FOL mutable movie sequence providing. We're way too protocol-y. And so we've actually implemented this for two things. One of them is actually a very lightweight thing. Think of iTunes, except think of it for movies. And so you'd like to basically have huge lists of movies, big cut lists of movies. But you really don't need to play them. You're really just kind of organizing them. It'd be like bringing up iTunes where you're getting ready for a party and you know all this music. You need to actually play it. You just kind of want to rearrange it and put it in a particular order. The next one is an actual hardcore editable, playable movie sequence, something where you can hit spacebar and it's just going to play for you. And so we implemented these two things as sort of objects on the palette there. So with that, let me go to bring up IB.

Everybody has to arrange their little IB world differently. Myself included. Yeah, see? You're right, aren't I? So let's just start off with a simple thing. Oh, document opening error occurred. Oh, that's good. We should have rebooted this machine. All right, we'll make a new one. See, I tried all my stuff on Panther, and then they put me on a tiger machine.

So the basic idea here is here's our little palette. Here we have a whole bunch of different objects, a bunch of which you're not going to get to see today. Sorry. So the first thing you want to do is you want to actually drag out this little object that has a bunch of movies in it. And because we are very firm believers in the sort of iterate really quick kind of thing, we actually have -- I can go and I can add and delete movies to this thing here, which I will later on this. But it comes up and it starts up having just a bunch of movies to -- a bunch of little test movies sort of built in there to provide out. So the first thing you want to do is, you know, pretty much what everybody else has been doing here, which is you drag out a little -- you drag out a little movie view. And in my case, I actually wire it up to a sequence provider. So now if I go into test interface mode, I actually go and build up a little sequence of those movies there. And so I just have this simple little movie that's there. Now that's not super interesting. It's sort of what the other guys were doing. And I'm supposed to be the sexy demo, so I have to do something better than that. So one of the things that is really, really neat about this and the thing that they got really right is the fact that this is very, and again, happy that most of you raised your hands on the Cocoa side of the fence there, is that this is, the QuickTime kit makes it very, very easy to make very MVC kinds of things. And so here we have a little table which is representing the movie and as we're playing this thing here, it's sort of showing up that stuff there. And we can do all the sorts of things you would expect. I can drag and drop these things around. Now what's going on here? I'm editing a movie. I'm editing a movie of movies here. It starts to get really interesting of where it's actually just updating this stuff. So we'll put some more.

I don't know why those guys don't want to open. That's weird. Anyway. we'll go and instead of having just a table view, we can use an outline view. And so you can notice now that when we get with some of these things, there were little disclosure triangles on them. And that's because these themselves are movies of movies of movies. So in our little test thing that we've got there, we actually have it set up so that it's not only just sort of one level of hierarchy, but it's two. And all the sort of stuff that you would expect to have work works, you know, you can sort of drag between them and stuff like that. And we're doing some heavy lifting there, but the fundamental QuickTime activity that's going on there is that little function that I put up there, which is basically all I'm doing is I'm inserting an element.

I've got sort of a companion one of that, which is basically delete element from segment. And these guys really did it right. It really sort of works the way you would expect it to work. And again, we've got, with the kit that we've been working on, we have a whole sort of raft of these UI elements. So let's just go and let's see if we go and we say, let's put that in a tab view, okay.

What did I put in a tab view? Something's been put in a tab view. So let's put this guy in a tab view there. And then we can actually go and we have another view, which is a tableau view. And so if we wire that guy up to-- sorry, not dragging the scroll view. And this guy will go-- and let's actually also drag out a little slider. So we'll do this sort of iPhoto kind of thing.

So we can see our movie that we have here as both looking at it that way or this way. And again, all the same kinds of things. We can go and move these things around. And then we can go and-- I should have made it continuous. That's why you want to use IB. So now when you go in there, you can try that sort of stuff.

I really want to take this moment here, since you're Cocoa folks here, to evangelize a few things. I came from the old Next Step world. That's sort of how I got to Cocoa. And one thing that used to happen a lot more in the Next Step world than it seems to be happening in the Cocoa world is people would put things on palettes.

And it makes me sad that I don't see more IB palettes. And I pushed really hard on the QuickTimeKit guys to get sort of all their ducks in a row on there so in terms of all the encoding methods and things like that are in there that you can actually go and put all this stuff in there, put it in a nib. And there's a certain rigor that happens when you actually go to the trouble of putting things on an IB palette. And there's a certain cost up front in terms of actually making it so that all your objects know how to serialize themselves out and that they're using key coding correctly. And there's some work you have to do there. But it's really worth it because there's nothing like taking down another app to know when you've got bugs in your code. And the cool thing about IB is I'm in and out of test interface mode there. If I'm not releasing everything correctly or I'm doing some bad trouncing on things there, I'm going to pay for it really quickly. And I much prefer to sort of take the pain of that kind of stuff not quite completely up front. But people don't sort of go and finish things out well enough, I think. And sad. I'm hoping people will see this thing as a non-trivial example that was basically done by four people that contributed to the code on this thing here. It wasn't a huge, huge effort, but it is something that you want. Take out, again, the obvious thing then that if you're going to really start trying to to do production apps with this stuff, the one thing that I think we all know that we need is a timeline. And so we have a little timeline view that we can drag out here and start up there. So here we have a little timeline. And same sort of stuff happens. You know, you've got selection. You can see it happening between them there.

We've got interactive. We can sort of change the in and out points on there and then indicate those things. And here's sort of a neat thing. So remember, this is a movie of movies inside our movie, right? So and remember that that little movie had, if we look, it had -- it was made up of three and four. But it's a movie and it has in and out points. So theoretically, we could actually change the end points of that thing and move it in far enough that it's sort of representative first frame is no longer three but four. And so that's sort of just proving that I sort of have no, you know, I'm not lying here. Another thing that you could do on this kind of stuff is you can use sort of non-trivial movies. Let's actually get rid of my trivial movies and show you some non-trivial ones.

So now, unfortunately, when I grab these movies, I grab them off the disc farm, and we made them from there. And so these movies have no sound. But they are real movies, nonetheless. And so this is some stuff from a little movie we're working on this year called The Incredibles. And so this was from the trailer. And so this is pretty interesting, because these are the real, are we, We're in a bad place right now. Let me just check this again, sorry.

IB for a second here and do this again because when things say they're being freed in the middle there, you probably want to start again. Okay, so if we drag out a little movie view here, and we drag out a timeline, and then we pull out a sequence provider, And then we'll go and we'll edit that sequence provider. And then we'll go add those movies in again.

And so what I'm hoping that you're getting from this is the fact that you can use this kit to do real things. These guys have done-- there's still, I think, lots of quick time left that's not really exposed in the kit right now. But I think there is an enormous amount of work that have done. So here's our little sequence here. And what's fun with this is that you can even actually edit this thing while it's playing. This is what I mean by it's magic. I didn't do anything to get that. You know what I mean? I'm just editing the movies of movies there and these QuickTime folks are just making that all work. And I don't really know what they're doing. And I don't have to know. That's the point of doing stuff with Cocoa, right? Leverage. It's all about leverage and trying to get and trying to leverage what these folks are doing so you can get back and do sort of the real work that you want to do. Is that the time for talk or do we need to leave time for questions? Okay, good. I'll wrap this up here.

So that's, oh, it's kind of dark up there. That's too bad. Yeah, this is actually a full film res Pixlet playing back there. And we can also, there's other things in the kit that I sort of haven't talked about, but I can do things like we have this notion of markers that you can drop down and you can drop markers on things and snap them to things, or we can put a, I could put like a marker here and then I can extend that thing out. And then I can do things like drawing on top of it there. And then I can actually go and just play.

And the drawing there is actually using a child window. So there's actually-- this is, again, sort of the magic of Cocoa, right? Is that I've got the child window stuff over here. So I did that drawing in a separate window that's coming in there. The Qt Movie View has no knowledge of that stuff at all.

The GPU is doing the compositing there. So I didn't have to draw some sketch track inside of QuickTime and then hope that QuickTime-- it was a fast path in QuickTime to sort of composite that stuff together, I can sort of have that little drawing up there, and this is the kind of stuff that we do all the time, and have it not cost me anything from QuickTime. And what's so great about this, again, from a Cocoa person's perspective, is that QuickTime's finally sort of arrived to my party, where they were having a great party over there by themselves here, but now I get to use them, and I get to make them plug and play with all the things, interface builder and child window stuff and just being able to build a framework and to be able to sort of move things around really easily. And that's just enormous and sort of what these folks have actually accomplished sitting on the shoulders of the giants of all the QuickTime efforts for the last ten years. I just, you know, I'm verklempt. It's just really huge. And so that's all I've got. Thanks.