WWDC2004 Session 216

Transcript

Kind: captions
Language: en
welcome to session 2 16 my name is Tim
Monroe I'm with the QuickTime
engineering group and in a little while
I'll bring up John crow me from Skylark
associates we're going to talk today
about alternative programming
environments or languages as they seem
to change the title for a quick time and
let me just start off by saying that in
all the digital media sessions we've
heard a whole lot about Moore's law
right it seems like everyone wants to
talk about more as well well I'm not
even going to mention the words Moore's
law during this talk but I do want to
talk about something which is really
more important and I want to call that
Twain's law and that is to a man with a
hammer everything looks like a nail or
as we might say today modulo hammers
it's all nails so the truth here is that
if you have a problem you want to solve
generally you are restricted to the
tools that you know about and so
sometimes we end up solving a problem in
the wrong way because we don't really
have acquaintance with the correct tools
so one of the things i want to do here
today is sort of throw out a survey of
some of the tools that we can use to do
quick time i'll talk a little bit about
how we can extend some of these tools to
perhaps take advantage of more than is
built into the tool and then in a few
minutes we're going to reveal to you for
the first time an exciting new tool for
windows developers so let's talk about
traditional development so what I talked
about alternative we do that against the
backdrop of what's the tradition that
we're working in usually and probably
for the first eight or nine years of
quick x development the standard way of
doing application development was using
the C programming language with what we
now consider to be carbon api's or what
we would then call the mac user
interface toolbox in the mac operating
system now on windows we can develop
quicktime programs but again the
standard programming paradigm is using
see with believe it or not the mac OS
toolbox and you
interface tool box and we do that with
this magical little thing called the
QuickTime media layer or q KML which
essentially is just a whole lot of the
Mac toolbox and a whole lot of the mac
OS taken over and put on top of Windows
and where you actually had some choice
in the traditional development model
within the Ides that you would use so
early on people would possibly use mpw
about the system 7 time frame we would
move to codewarrior very good tool on
Windows you might be using visual studio
and then nowadays you could still do the
same sort of development using Xcode
well that's okay that's great but today
I want to look at what's possible apart
from this traditional model and I've
sort of roughly classified these into
three major groups the first group is
what's really fun and that's what we
would call rapid application development
tools so we've got cocoa we've got some
very good third-party tools real basic
and runtime revolution on the windows
side we have visual basic and Delphi
there's this news kid on the block
applescript studio and then there's this
thing hypercard that doesn't super cards
it doesn't even want to go away so all
of these development environments have
some built-in support for QuickTime
actually there's one of these that
actually has no built-in support for
QuickTime anybody know what that is
visual basics put out a company by a
company up in redmond and for some
reason they seem to have left out the
QuickTime support in their application
and I'm sure this is just an oversight
but enterprising third-party developers
have actually stepped into this void and
developed what's called an activex
control so the way you would in visual
basic use QuickTime is by finding an
appropriate quicktime activex control
adding it to your project and then going
from there now here is there sort of an
embarrassment of riches there are in
fact three different activex controls
that you could get right now to do
application development in this
basic on Windows it turns out that to do
even a basic multiplayer a multi window
player application that allows you to do
editing and maybe some extra stuff none
of those three existing activex controls
gives you quite what you need so it's an
embarrassment of riches but it's also
embarrassing Lee bad and that you can go
very far with any one of those three so
then we have for that I'll what I'll
call application frameworks so they're
not really rad tools or maybe some of
these are i don't know quicktime for
java with the job of quicktime java was
quick time for java bindings very good
story for developing quicktime
applications there's a cross-platform
application framework called cute or
cutie there's one that's apparently not
very well known called wxwidgets it used
to go by the name WX windows but for
some reason they had to change the name
and then there's a good good old power
plant provides a good basis for
supporting quicktime applications the
last category i want to talk about is
actually quite an interesting one and
what i've been working with recently and
that is what we wouldn't might call
scripting scripting in the sense that i
have a text file i type in some commands
and then somehow those commands get
interpreted at run time to give me a
quick time application the one that i
will look at in depth is tickle TK with
an add-on called quicktime tickle it's a
very interesting little environment
we're going to be looking at a mystery
guest that I won't tell you about and
then I have question marks by Python
Perl and Ruby and the reason I have
question marks is that to my knowledge
there's no out-of-the-box solution to
use for instance pearl to develop a
QuickTime playback and editing
application but once you see what I do
with this mystery guest I think you'll
be convinced that you could if you
wanted to use these three other
scripting languages to build a QuickTime
application
so let's take a look here at the old way
of doing things so I'm going to look at
what what used to look like what I've
got here is codewarrior and I've got two
two projects files opened one of them is
a Windows project file and one is a
Macintosh so the first thing that's
interesting and perhaps some you don't
know is that here on Mac OS 10 I can
build compile and Link an application
that will run on windows so this is very
nice so if you've done any quicktime
programming so far and you've looked at
any of the sample code you've probably
bumped into this little guy QT shell
it's a bare-bones quicktime playback and
editing application that allows you to
build for either windows or mac let me
bump this up a little bit so we can
actually read it you can see that the
files in each of these two projects are
very similar there are two whoo that's
cool there's one here called win
framework which is as you might guess
some basic application support geared at
the windows application on the mac side
you can see there's a mac framework
which is the same stuff for the mac side
there's some common stuff which is
really where all the quicktime support
lies and then there's this complication
which is where I would put any
application specific code and in QT
shell that's that's fairly empty that
file so let's look at winn framework see
no that's okay No
so here we've got just some standard fee
source code let me bump down here a
little bit one nice thing is we're
seeing Windows data types here bool
handle H wind cars we've got LP stirrers
here so and let's just look down and
here we've got a window proc or where
this is our wind main where we set
things up and if you've ever done any
windows programming you feel right at
home with this this is just the kind of
stuff that you expect to see let's just
go down a little bit more and we
actually have a window proc for our
frame window so this is an MDI
application and we have a wind proc for
the movie windows inside of there so
this is a good story right there that's
the kind of mindset that Windows
developers have if we look at the
corresponding file on the Macintosh we
get pretty much the same picture okay
here's max data types this is the stuff
that carbon programmers understand if we
go down here we'll get to installing
some carbon event handlers somewhere
down here we've got event loops that's
wonderful so again if you learn how to
program on mac that's just the sort of
stuff that you expect to see now let's
look at the common file and see what
we've got in there now as I said this is
mostly QuickTime specific stuff okay
we've got some platform-specific defines
here that's okay I can handle that down
here sort of we've got a file menu
handling that calls application specific
functions here that's good again some
more wrappers for the edit menu now
we're getting some quick time functions
here MC cut its how we're going to
handle the cut command and so forth
let's go down a little bit further see
what we run into fairly generic stuff
here here's a nasty guy FS make FS spec
for Windows programmers this is wrong in
so many ways right they don't want to
have to work with FS specs
Epis spec is a is a relic of the mac
operating system so the barriers to
entry for this kind of development for
Windows programmers are fairly high
we're asking them to learn not only the
windows way of doing things but also the
Mac way of doing things so again that's
a bad story so let's go back to slides
that's also a bad story for cocoa
developers right they don't want to have
to work with those carbon data types
they'd rather work with stuff that's
good for cocoa well if you were at the
last session the the cutie kit session
you saw that we have a very good story
coming out in tiger for cocoa
programmers we have this new cutie kit
that insulates the cocoa programmer from
as much of that underlying stuff as
possible wouldn't it be nice if we could
do the same thing for windows and I want
to invite up John to show you that we
are announcing here exactly that same
sort of thing for Windows developers
please welcome John Berman thank you Tim
I must say it gives me a kind of a
perverse pleasure if you like to be
standing up here at the Apple Developer
Conference and talking about of all
things visual basic activex and calm but
whether we like it or not visual basic
is probably the most popular programming
environment ever there are about eight
million developers out there using
visual basic and with visual basic net
and with C sharp now using many of the
same ideas from from Visual Basic that
development base is buying to grow in
the coming years now much of the success
of Visual Basic has been based around
the component architecture that
underlies the visual basic platform and
that is called calm component object
model and it's quite a similar story to
quicktime in a way quicktime was based
on a very successful
at architecture that underlies the
platform and if you're a calm developer
or a visual basic developer and
attempting to use QuickTime as tim has
mentioned the choices were rather
limited and some of us have been trying
since in visual basic three days to
attempt to use QuickTime in visual basic
to develop QuickTime applications in the
calm or Windows environment but with
limited success so I'm delighted to
announce today that Apple is finally
addressing this problem and announcing a
brand-new QuickTime com or activex
control for QuickTime developers this
control can be used in out of the box in
the.net development environment and also
in traditional calm development tools so
we're talking about the leading RADS
development tools here we're talking
about vb.net we're talking about c-sharp
we're talking by Delphi those are the
three big ones but the comm technology
underlies many other development
environments and underlies many other
desktop applications as well and because
of this shared calm environment the
QuickTime activex control can also also
brings QuickTime technology into those
environments as well so rather than
stand up here just describing this
control in detail I'd like to take you
through a short development sequence
what we're going to do is put together a
very simple movie player and editor
using the new activex control
switch through the thank you okay so I'm
going to launch vb.net well in fact I've
already launched vb.net and I'm just
going to drag in any sample application
okay so this is the anybody who's used
visual studio.net or vb will recognize
this environment we've got a form here
and I've made life easy by already
populating the form with some menus but
basically this application does nothing
as is so the first thing we have to do
is to put the new quicktime com controls
on the form now I like most windows
controls the comm control resides in
this tool box containing hundreds of
controls and it's in here under the
general section sitting beside a friend
so let's pop it on the forum there we go
so the first public instance of the
QuickTime calm control I'm going to
press f4 and get some properties and
this just shows the way in which you can
manipulate the control in the design
environment so I just want to change its
name and make it might be slightly
simpler I'm going to give it a plane no
border and i'm going to set its position
to be 0 comma 0 okay now i double-click
and we go into the code behind the form
now visual basic fills in a lot of this
when you add the menus visual basic
fills in the prototypes for the various
functions so most of this code has
already been written for me and I'm just
going to start filling in the actual
bits that depend on the control itself
so first thing we want to do is we want
to open the movie so we go to the
to the handler that handles the open
menu item I've already put in some cold
here that gives us a file dialog to
choose a movie so in a few lines of code
hopefully less than six lines we can
create a simple movie player application
cutie control one dots and this is when
it gets interesting because this
autocomplete or intellisense technology
really comes into its own because what
we see now is a drop up sorry pop up
menu with all of the interface methods
and properties relating to the controls
so I'm going to choose URL and we're
going to set the URL equal to the file
dialog dot I'll name there we go
syntactically checked and all for me now
want to implement a few other things so
let's allow ourselves to close the movie
set the URLs nothing and let's make sure
that when we quit the applications the
movie also gets closed properly now what
do we want to do with the movie we want
to be able to play it remember this is
really basic stuff ok dot oops dot now
this time instead of telling the control
to play I actually want to tell the
movie which is inside the control to
play so we pick the next object in the
hierarchy and press dot again this time
we get us we get a different set of
methods and properties relating not to
the control but to the actual movie
itself somewhere here we've got play ok
and just to show that we can do other
things as well we've got dot rewind ok
so let's leave it at that for now let's
run this application ok so it's building
a binary and here we are so let's try
opening a movie and here we've got a
movie whoops it's set up there okay
rewind it and I can play it okay so very
simple quick time application developed
from a visual basic skeleton in a matter
of minutes that's the power of the new
quicktime com control but obviously we
want to do more than that and the
control is quite fully featured so what
I'm going to drag in now is a slightly
more bait version of this skeleton
application most of the code has been
filled in now but we're going to add a
few little interesting bits first of all
we've shown we've seen how to tell the
movie to do certain things send commands
to the movie now we want to see how do
we get some information back out of that
movie so what I've done is I've set up a
little media inspect reform and what I'm
going to do is put some code in there
here you can see the code here i can add
properties and i can add sections to
this little form and we're just going to
type in some code so let's get the
duration of the movie the widths the
heights some metadata some user data
from the movie so QT control 1 dot movie
dot duration okay and to save you and me
a lot of time I'll just copying the rest
here we go
oh there's one more thing I'd like to
show you notice this one here track 1
let's put into this little information
dialog the data format with a media
format of the first track of the movie
ok so we're starting to drill down into
the movie here let's see how we get this
so we start off with the control cutie
control 1 dot movie dot watched inside a
movie tracks we want the first track and
we want it's a result its format ok so
without looking up any documentation
virtually I can use the auto complete or
intellisense technology to work out what
roughly looks like something I might
want so that's getting information out
of the movie now anybody who's developed
a QuickTime application will know that
very soon you need the movie or the
control to tell you what's going on
inside in other words you need to be
able to handle callbacks or
notifications now if you're a visual
basic developer and you've never come
across C++ or C before you don't know
what a callback is you don't know what a
notification is even the only thing you
know about our events and sure enough
we've added to the QuickTime control the
suite of events which allow the control
to tell the application or the
underlying its parent window if you like
what's going on in the control now in
this simple application we would very
much like the the container window to
resize itself to fit the movie so let's
have a look done see what events are
here remember I haven't looked up any
documentation I'm using this for the
first time there's a size changed event
that looks kind of reasonable and here
is the prototype the DB puts in for me
so the form i'm in is called me and i
want to set its clients eyes okay the
bit inside it and I want to make it
equal to a new sized object this is all
standard vb and the size object is to t
control 1 dot width and QT control 1 dot
height okay there we go notice the wavy
be immediately syntactically checks the
whole thing for me and underlines
anything that's wrong now so that's the
control telling application when it's
changed size but as a quicktime
developer you're probably familiar with
MC action events with the need to set up
a filter proc and to get information
back from the movie what I'd like to do
is to have this application know
whenever the movie is playing and when
it isn't playing in fact what I want to
do is I want to make the play item in
the movie menu change from play to stop
and stop to play whenever the movie is
playing I'm stopped okay in other words
I may want to make a context-sensitive
menu first of all let's go back up to
the code for the play here we are and
let's modify this so let's say if cutie
control 1 dot movie dot rate if it's
greater than 0 0 then if the rate is
greater than 0 we want to make it stop
so movie dot stop all the things you
could you might expect her in here and
play okay great that that will work fine
that will stop and play in the movie but
what it won't do is it won't change the
label on the menu from play to stop and
from stop to play so that will be a nice
touch
and in order to do that effectively what
we really want is for the movie to be
able to tell us when it's playing or
when it stops this is where we come to
the events that are exposed from within
quick time now the way this is
implemented in the QuickTime com control
is that all of the objects within the
control have an event listeners
collection and if you're interested in
an event within the control then you
register for a particular event so what
I'm going to do is immediately after
I've opened the movie here i'm going to
type QT control one movie dot event
listeners dot add we want to add a new
event listener notice the various
options are popped up immediately for me
I don't have to look up any
documentation I want a high level event
and I want to choose the rate changed
events here okay and I'm so that tells
quick time or tells the control to let
me know when the movie rate has changed
so how do we handle this event when it
comes back to us well all of these
events from within the movie are all
marshaled through a single QT event call
back or event handler within visual
basic here's the prototype for it now
rather than typing in code I'm just
going to copy this here and paste it in
now because you can get event lots of
different events that you might register
for here you might register for an event
when the volume has changed when the
time has changed that kind of thing when
a sprite has moved lots of kind of
things you can register for so obviously
we need a case statement in here so we
can do what you'll want to do at
particular times so if I have a case
here on the event changed event and I've
got some cold here which simply looks at
the movie rate and determines whether or
not the
menu play menu item should say player
stop okay so let's let's leave it at
that let's save this and build it
hopefully it'll all work okay open a
movie let's open a different bird this
time not be eaters okay first of all
immediately we notice that the the
application window is resized to fit the
movie now remember that was one line a
very simple straightforward code not
only that but we can scale and the
application windows scales as well to
fit the movie okay let's see if our play
button works okay good okay let me press
the spacebar Nordic said it's ready
change we stop okay that's because we
know that our event callbacks are
actually working here so what else can
you do with this control well I've got a
fully baked version of this application
which I'm just about to show you now
full screen works as a single call cutie
control movie full screen equals true so
I'm just going to launch finished
finished application here and do one or
two quick things with it let's kill
studio and kill that and open another
movie
okay so i've got a movie over here that
i've opened in quicktime player and i'm
going to say file new movie here okay so
I've created an empty new movie I'm
going to grab a bit of this a little bit
of this snowy egret and copy it I'm
going to go over here and paste it
what's the command for pace
beauticontrol one dot movie dot paste
very simple I've now I've got a new
movie here okay I can cut a bit out of
it if I like okay but best of all I can
go to export movie and all of the
exporter's that are available to
quicktime are available here to the vb
developer let's give it a name Egret
mouth okay so within the code I popped
up the export settings dialog I can go
and change those and it's basically
exporting the movie at the moment okay
and it's done so let's close this movie
and opened the one we just exported
oops how to happen but basically you can
export movies from within the
application I think I didn't wait until
the export finished so that's visual
basic.net now to develop in c-sharp is
very very similar in fact the cold is
almost identical to slight slightly
syntactically different can we have the
slides again please anybody who's
developed in QuickTime or sorry in
visual basic will know that the object
model is something that you deal with
very often and in order to expose the
QuickTime API in a way which made sense
to calm developers we've imposed an
object model if you like on quicktime
and you can see on the right hand side
of the slide here that some of the
elements of that object model and it's
no coincidence that there's a lot of
commonality between this object model
and between the object model that was
being described earlier as part of the
QT kit okay in other words the object
model of quicktime transcends the
implementation details of how you
actually use quicktime and that's really
important thing to understand if you
understand the object model as a
developer then you really you can
develop with QuickTime and lots of
different environments just want to
emphasize as well many of you might have
turned up your nose when I mentioned
visual basic and see developers have
have a habit of doing that let's not
forget that these environments
particularly c-sharp Delphi and visual
basic can all be used to produce very
professional quicktime applications so
those are the big three visual basic c
sharp and vb.net but there are others
and many development environments are no
comma where there's a few listed here I
want to draw your attention to one in
particular which I've been
really enjoying using and that is the
trolltech QT framework or cute framework
it's brilliant for cross-platform mac
and windows development but it's also
very good on windows because it has an
excellent calm container class what i'm
going to do is very quickly show you we
just have the okay acute application
which is identical to the visual basic
application that i've just developed all
the quicktime implementation uses the
quicktime calm control is nothing fancy
going on here and what I've added a
little extra to this because it was so
easy to program with a few lines of code
I can grab series of interesting faces
let's end with a happy face drag them
over here oops this is going to crash
sorry start again should have created a
new movie first
okay let's create a new movie okay let's
grab some interesting faces again and
drop them over here so these are images
that I'm dropping on a cute quicktime
application you notice that it's now
creating a movie out of these images the
code is really really simple here it's
maybe four or five lines of code and
I've created a simple drag-and-drop
droplet if you like for creating
QuickTime movies from content on your
desktop and because i can get at the
export menu kind of another go at
exporting i can export these as a DB
stream i'm going to put these
okay setting is again and it's exporting
at the moment so let's give it a bit of
time this time close the movie open it
and now we've got a DV movie created
from those okay using the QuickTime
object model within the control I can
play with all of the various export
settings and as you can see here you've
got the bones of some quite powerful
production tools back to the slides
please so there's a couple of other a
couple of other development environments
which you shouldn't forget about draw
your attention particularly Delphi tool
book as well lots of developers using
QuickTime in tool book on Windows using
a calm control as I mentioned before the
QuickTime an abstraction is exactly the
same everywhere however because calm
underlies not just developer
environments but many desktop
applications then all of a sudden we've
got the ability to use QuickTime in
places that we might never have dreamt
of before
so let me just show you this
anybody recognize Excel I've got a list
of movies down the side here and I can
click on a movie it opens up with in the
middle of my spreadsheet and lo and
behold with a few lines of scripting
code behind this worksheet I've been
able to populate some cells in the
spreadsheet with various pertinent
details from the movie so for example
there is the copyright or the full name
ok but not only can I read information
from the movie why can't I just type
grieve in there for the name John for
the author and click on the save movie
cell ok just to show you I'm not doing
anything behind the scenes I'm going to
go and delete the contents of these
cells click on a different movie click
back on the same movie again and you'll
notice that the name and the author has
changed on that movie now I won't waste
time by going into QuickTime Player to
actually show you that that's happened
but believe me that is actually changing
the user data in the movie now this is
really useful if you're
production-oriented have a look at this
example ok I've got a folder of movies
here and now there's only five movies in
this folder but you know there might be
500 movies and I'm going to read for
user data fields from these movies for
metadata fields and my problem is that I
want to change the copyright on all of
these ok so let's change the copyright
to 2005 it's a spreadsheet so why can't
we just do a edit fill down and let's
save the movie data so we're opening up
each movie in turn and writing this data
back to it from the spreadsheet that's
clear
it and get it all back again and notice
that very quickly and very easily we've
changed the copyright on a whole folder
of movies that's XL many of you probably
don't realize that behind XL on Windows
is a very powerful visual basic
programming environment virtually
anything you can do a visual basic you
can also do in Excel lastly a very quick
demonstration of another popular
environment PowerPoint can we use the
QuickTime control and power point of
course I think yep so here we've got a
movie I've added some buttons to the
PowerPoint slide and then I can play the
movie okay that's very simple but you
can also do more here's a movie which is
essentially a chapter movie it's
actually a smile movie which creates a
series of chapters and as you can see
it's standard quicktime chapter access
but what happens if i want to get at the
chapters using buttons within PowerPoint
well again a few lines of scripting code
behind the slide and we can jump from
chapter to chapter within the movie last
slide a little bit of fun some of you
might remember this interesting wired
sprite movie this this is really to
demonstrate how deep you can get within
the object model with in quick time I've
got two buttons down here this one turns
off the left eyeball and this one turns
off the right eyeball how are we doing
this quick cutie control movie dots
tracks sprites dot one dot visible
equals false or true okay
or or you can make them go cross-eyed by
enlarging each of those sprites so
essentially within simple desktop
applications like this with the visual
basic environment behind them we can use
the common control to do interesting
things with quicktime lastly I just
wanted to come revisit the cutes
framework one more time okay I mentioned
that it was very good for cross-platform
development and if you choose to use on
the windows side the new quicktime com
control and on the mac the new high
movie view then you can actually create
quite powerful cross-platform
applications which share a lot of the
code here's one I've been working on
this is an application that's going to
ship hopefully shortly it's all about
birds believe it or not and then we've
got a QuickTime movie and fortunately
using virtually the same code I can
create a very similar application that
runs on the Mac
ok so this uses a cute framework all the
code is cross-platform virtually much of
the QuickTime API code is also cross
platform and yet we've got
identifications that look very similar
on two separate platforms with shared
development effort that's really all I
want to say any questions afterwards
about other frameworks or other calm
environment so I'll be happy to take and
back you Tim ok so let's switch gears a
little bit we've been looking at
standard application development tools
on Windows and also on Mac we've seen
that there's some really good high level
solutions coming the QuickTime kit for
Coco developers the new activex come
control for Windows developers for
carbon developers we also have a new H I
moving view that I haven't talked about
here but which you should look at now
what I want to do is look at this sort
of scripting languages and again this is
pretty cool let me come over here to
demo one and open what I'm going to do
is just show you the text file so this
is written in a language called tikl if
we look at this you can see that i can
define procedures so the nice thing
about tickle it's fairly readable it's
got to see like syntax it's not pearl
mere mortals like me can actually
understand this one nice thing about
tickle is that it's closely tied with a
graphical user tool kit called TK and
the last cool thing about tickle is that
somebody cared enough about tickle TK to
actually spend time developing a
quicktime plugin that lets you open and
display and edit and export and do all
sorts of things with quicktime content
using a purely scripting language so let
me show how you can actually run this so
this is just a text file i'm not going
to compile this i'm not going to link it
what I'm going to do is launch an
application called wish shell so when
you install tikl TK this application
gets installed and it has a console here
so this is almost like a terminal window
I can type in if I happen to know them
some tickle or TK commands and they will
execute here so I'd say tickle TK
interactive interpreter i'm going to
type in a TK command top-level let's
call it su top level is the way you
create a new top-level window so i'll
hit return there and lo and behold
instantly i have a new window on the
screen so by typing in some commands i
get a nice gooey element so let's so
that I quit that alright let's launch it
again now I showed you that script of
actually quite lengthy script of tickle
TK and quicktime tickle commands I'm
going to open that with a source command
here I'm just and what we notice is that
the console window and the the the basic
window it gives me have gone away i
explicitly hid those and now i have a
menu bar with commands that look fairly
reasonable for QuickTime movies so let's
see if I can open a QuickTime movie okay
here's some MPEG fours and it will play
them just like you'd expect I can come
in here and cut I can come over here and
say paste oh maybe I like that clip so
much i'll paste it again one nice thing
about quicktime tickle is that i can
then come back here undo the second
paste undo the first paste excuse me
undo the cut so i have unlimited levels
of undo so that's really pretty cool i
showed that earlier on monday for the
cocoa kid and you expect that with cocoa
you don't necessarily expect that with
just a standard scripting language so
that's quick time that's tickle TK and
quicktime tickle let's go back to slides
briefly now it's time for our mystery
guest okay and I won't reveal what that
is let me motivate that first so let me
quit here let's open up a terminal
window and I have some commands have
already run here it turns out that if
you let's try this if I LS user bin
[Music]
let's see what matches user been w is
star I have three things there so when
you install tikl TK you get not only
that gooey app that I launched but also
these tools that you can run on the
command line and I've already
prepackaged some commands here so let's
notice it command one here it says echo
WM withdraw dot that means hide the the
window that it opens then do top level
foo which I did before and pipe that to
one of those wish command so let's run
one there see what happens lo and behold
that wish application opened and it did
what I wanted it hid the the default
window you get and it opened a new
window called foo so what does this tell
me it tells me that I can use the
standard input of that command line
version of the tickle TK interpreter to
do command now I've also got another one
here let's do 33 is says echo this
command that's some tickle script that
means put string hello world pipe that
through the tickle TK interpreter and
let's see what it does it echoes hello
world so that's sort of a roundabout way
of doing the hello world thing namely
send this string of tickle commands over
to the tickle TK interpreter and the
tickle command is just to your standard
output
right this string so what have we
learned that command line version of the
tickle TK interpreter take standard
input it's got a standard output now
here lights may be going on in your head
you can do some pretty funky stuff here
why well I could write a shell script or
a perl script or whatever that sense
some standard output to the tickle TK
interpreter and if I was clever if I had
a bi-directional pipe I could get some
output back so what this shows us is if
I know some chick as a DK if I know TK
well enough to be able to do the
graphical user interface stuff I don't
need tickle at all I don't need that i
could write my application in some other
language all together so this is where
our mystery guest comes in so what I did
is when I had that realization that I
can just plug in any language I want and
as long as that script for that language
or that application knows how to write
TK to its standard output and read
things in from the standard input I'm
golden so can we go back here my mystery
guest so what I was doing I was looking
around the UNIX system and I came across
a small little language hasn't been used
in years and that language is awk so I
decided I would write a full feature to
quicktime application using just awk and
let me show you that that actually works
so I need one more piece of this puzzle
I need something that takes the standard
output of the tickle TK interpreter and
sends it to awk and then I need
something that takes the standard output
of awk and sends it to the tickle TK
interpreter so I wrote a little perl
script and because this is sort of some
glue between arc and wish I call it the
awk to wish adhesive or I like to
abbreviate that is aqua so here I've got
the aqua interface between off
and the key k interpreter and i'll just
do 12 here again so 12 just says let's
run this perl script doesn't look like
anything's happened because i don't know
how to sell pearl to make the
application come forward down here in my
doc this is an awk script running
quicktime well there's no QuickTime
movies here it's just an about box let's
see if we can open a QuickTime movie
this looks just like it did before
because the graphical user interface
portion of this is identical all that
has changed is that I've taken a
perfectly reasonable scripting language
namely tickle and replace it with a
perfectly ridiculous scripting language
namely awk and again I can play this
I've got the multi-level undo and redo
I've got everything I had for ok that's
pretty cool let me end with one last
thing
so actually Kevin talked about this
yesterday in his session turns out that
sometimes we want to operate on
QuickTime movies but we don't
necessarily want to actually display
those movies so we may have a bunch of
movies that we want to transcode into
some other format or we may want to
create a QuickTime movie from a bunch of
still images I think we just saw this a
few minutes ago John grabbed a bunch of
images and he dragged him into his
little app and it put them together into
a movie but even there he was showing a
GUI so what if I just had a whole bunch
of images lying around on my desktop and
I wanted to make a QuickTime movie out
of them well I'm kind of slow so I
thought jeez that's a wonderful solution
i've just got I know that quicktime
tickle has this command where i can add
frames to a movie and it can create a
new movie and it can write it out to
disk so I'll use this great technology
this aqua technology I've got and I'll
write a quick time I'll write some sort
of script that sends the TK commands
over to quicktime tickle and suddenly I
realize that's not what I want to do at
all what I want to do is just write a
command line tool that takes as its
parameters the names of the files I want
to use and creates the movie and let me
just show you that here I've got an
Xcode project but using H code is way
overkill for this I could just do this
all in the command line that's wonderful
so it's real simple I've got an a main
routine here it's got some arguments one
nice thing about this script is I'm
using the latest and greatest quicktime
api's so I do a little checking on my
the number of arguments i get i don't
get the right number i'll print out some
nasty warnings I'll call enter movies to
initialize click time there's actually a
step missing here that I don't have in
theory quicktime likes to have a graphic
support available when it's doing stuff
even if I'm not
going to display any QuickTime movies
it's generally a good idea to have a
graph court lying around so at this
point I should call open Newport is that
what it's called and have a port lying
around turns out I've never crashed
without it so let's not bother so the
first thing I want to do is grab the
first thing on the thought on the
command line and do a CF string create
with C string so you're giving me a C
string on the command line and I'm going
to get at CF string from that I want to
see up string because there's this
wonderful new quicktime data reference
utility called cutie new data reference
from CF from URL see of string and what
that gives me back in its parameters is
a data reference and the type of a data
reference again a data reference is our
standard way of referring to something
on the disk or something out there on
the internet or something somewhere once
I've got a data reference I'm going to
use this new quicktime storage API
called create movie storage it takes the
data ref and the data ref type it takes
the type of file I want take some flags
and it gives me back a data handler and
a movie so now that I would just a few
lines of code check it out what the
output file should be called and created
a movie I can loop over all the rest of
the command line parameters which
presumably our URLs to the images and I
do sort of the same thing I get a CF
string for the argument I get a data
reference from it I'm going to open the
image as a movie and I can do that with
open movie storage get the movie finally
when you do that when you open an image
as a movie at least on Mac OS 10 the
duration of that movie is I believe a
fifth of a second that would be pretty
small for the slideshow I want to build
so I'm going to scale the movie segment
from the movies that i just opened
to some predefined duration finally I'm
going to insert that segment that I just
scaled up to be the right size into the
movie that I created I'm going to do
that for every image on the command line
finally I'm going to update movie and
storage which writes out the new movie
and I'm done so here was about I don't
know maybe 30 lines of fairly up-to-date
quicktime api's i have a command-line
tool that i can specify a whole bunch of
image files to and then it will create a
movie for me all right so let's go back
to slides so that was the case study for
command line tools so let me just wrap
up I hope we've shown today that we've
got a whole array of interesting sorts
of tools that you can use to build
quicktime apps not only GUI apps but
also command line apps that it will do
useful and interesting things many of
these tools have very standard ways of
extending them for instance real basic
or revolution you can write plugins for
if there are quicktime api's that they
don't support natively and I really
think that right now is the best time to
be developing quicktime software and
we've seen this conference really
important new tools that quicktime coco
kit the activex control and things like
this that really brings us into the 21st
century so you can contact John or me
and let me just refer you to a couple of
sources information mac tech magazine
starting back in december of 2002 has
had a nice series of articles about
various quicktime programming
environments so virtually everything
that i've mentioned here today there
will be at some point in this duration
an article or two that describes how to
do that and much more detail than we've
had time to do here and also there are
two new books out from morgan kaufmann
that if you're doing any kind of
QuickTime programming you really owe it
to yourself to pick up there called
quicktime toolkit
vol 1 in quick time to get volume 2 and
that brings us back to was it Twain's
law that a man with a hammer sees
everything is a nail there is the cover
of the book