WWDC2003 Session 730
Transcript
Kind: captions
Language: en
thank you very much the first question
you should have is alternative to what
and I would guess that somewhere between
99 and a hundred percent of people
developing quicktime software right now
are using a fairly restricted set of
tools either their programming in
straight c or they may be using an
object-oriented language like c++ or
objective c or objective c plus plus or
even java and these are all of the
family of c oriented tools what i want
to look at today is some other
programming environments that we could
use to develop quicktime applications so
what are we going to learn today well
that's me and Keith we're going to look
at how to build a QuickTime application
and we're going to do it in 10 minutes
or less and for several of these
environments we're going to do it in 10
lines of code or less once we've done
that we're going to look at some ways to
extend the built-in support for
QuickTime in each of those application
environments along the way we will
encounter some limitations that these
various environments have and we'll also
look at some ways to work around those
when finally at the end i will give some
guidance to the people developing those
development environments as to how i
think they could be made even better
than they are now so we've got a full
plate today we may not get to QA but I
think you'll enjoy what we've got so
these are the standards that is I recall
is I'm guessing most people are using to
develop quicktime applications Metro
works codewarrior on mac and windows
probably using c++ and perhaps the power
plant application framework if you're
developing for windows only you're
probably using Microsoft developer
studio possibly with mfc application in
a framework
and if you're developing for mac only
chances are using the new apple ide so
what are some of the alternatives well I
went casting about to see what I could
use to build quicktime applications
without resorting to those old standards
and i came across at least these eight
and if anybody knows any other ones i'd
love to hear about them I don't have
time to talk about eight different
programming environments today so i'm
going to pick the top four there these
are all similar in many ways as we'll
see and one nice feature that they have
in common is that they're what we call
rapid application development tools the
idea being that in very little code with
very little pain and indeed as I've
claimed in 10 minutes or less you can
get an application up and running that
will do what you want so let's discuss
what we want to accomplish with each of
these I'm not going to build a full
multi-document application in any of
these so I've got to sort of limit what
I want to achieve so for each of these
four environments I want to do three
things really I want to be able to
prompt the user have the users select a
QuickTime movie file I then want to open
that movie file in a window on the
screen that is sized to contain just the
movie and the movie controller bar so
really there's three things I want to
find a file I want to open the movie in
the file and I want to size the window
to exactly contain the movie and its
controller bar now once I've done that
the hope is that the window will present
all the standard means of interacting
with the QuickTime movie so basically
cow mouse and keyboard input should work
as you expect it to and one final and
very important item once I've done all
that and I've got my movie open on the
window open in a window on the screen it
shouldn't matter what kind of QuickTime
movie I've opened
quicktime can handle a large range of
different media types sometimes we tend
to think of it as video and sound but we
have things like quicktime VR sprites
animation flash and the eye in the ideal
world each of these applications would
handle those things perfectly and let's
show what I mean there can i get vga too
I guess so I've got a selection here of
movies I'm just going to drag them all
onto a sample application now this is
the kind of thing that most people would
write it's a sea-based application the
code has been on the web for this for
years here I've got your standard music
video opening a window on the screen
there really is audio here I guarantee
you okay so that's what most people tend
to think of it a QuickTime movie here's
a different kind of QuickTime movie this
is a sprite movie and this is a wired
sprite movie so I've got this little
icon bouncing around inside the the
movie window here is a similar-looking
movie but it doesn't bounce but I can
drag it if I come over here and click on
it so I'm getting Mouse interaction
there here's a quicktime video effect
movie it's a fire that just burns here's
a quick time VR movie this is a rendered
panorama not photographed again it's got
a different sort of controller bar down
here and finally here's another wired
sprite movie so I click on the penguin
the other one moves around okay so
that's really the gold standard of what
does the kind of inter activities I need
for each of these development
environments first one I want to talk
about is real basic a very nice
development environment it's been around
on the Macintosh for quite a while and
recently has been ported to work on win
as well it's published by a company
called real software as I said it's a
rapid application development tool will
get a better feel for what that means in
just a second the language we're going
to use is an object-oriented variant of
basic as i said the ide runs on mac and
windows and you can build applications
on either ide to run on mac and windows
and for present purposes what we're
interested in is that there's built-in
support for playing QuickTime movies
using what they call a movie player
control so I think we're ready for a
demo of that so I'm going to come over
here and launch real basics I'm using
version 4 or 5 to there's actually a
newer version out there but I haven't
got it yet and don't want to change
horses in midstream so when i launched
real basic i get an empty window here
that's going to be where the movie is i
have a window that shows me what's in my
application right now i have a palette
of tools that i can use and then i have
a properties window which will tell me
for the given selected tool what its
properties are so the first thing I'm
going to do is grab this little
quicktime icon and drag it into my
window i want to put it up at the top
left corner there you can see the top is
a negative one so let's bring that down
I want the movie to exactly fill the
window so I'm going to uncheck this
border property if I were saying in part
of a window I might want a nice border
to delimit the movie and that's my setup
for the window I don't need to resize
this control although I could to fit the
window I'm going to do that later
programmatically with code so let's do
that i'm going to double-click on the
movie player control and it brings up a
code window so I can attach code two
elements of the interface here I'm not
interested in the play event I want to
attach some code to the open event
so when this window opens and the movie
player control opens the code that I
type here will be executed so what do we
want to do remember I want to do three
things I'm going to find a file open a
movie in that file and size it
appropriately so the way I get a file is
get open folder item I need to tell it
what kind of file I want i'm going to
use want to open video quicktime this is
just a mime type specification okay now
this is going to present the standard
file opening dialogue box and it's going
to return to me a path name or an item
actually not a path name but a an object
called a folder item so i'm going to say
items equal to the result of that and
since this is basic i have to declare
that variable and it is of type folder
item notice there was the code
completion all I had to do is hit tab to
to get what I wanted there okay once i
have presented the file opening dialogue
box the user has selected a quicktime
movie file because that's all they'll be
able to select i want to make sure that
i got something so if item is not equal
to nil then i'm going to have a block of
code okay and what am I going to do
there what is the object of this code is
attached to its a movie player object
that movie player object has a property
what its movie is so i can say my movie
or movie is what it's the result of
opening that item as an editable movie
finally I want to set the height and
width appropriately so i can say me dot
window dot width equals what it's going
to be the controller width of the movie
that i just opened and now i'm going to
copy and paste that do the same for
height and height and i'm done i can
close that in theory i could run this
but actually it won't work i need to do
one for the thing I need to tell real
basic what kind of file types I can open
so call this up and i will add it was
this nice pop-up list it goes on forever
video quicktime it fills out all the
parameters for me okay okay now let's
try it we can actually run this within
the ide by hitting run there's my file
opening dialogue box i'll choose a nice
music video here it opens it sizes it
and let's see if it works perfect
so how many lines of code was that it
was one two three four five six seven
really seven lines of code select a
movie file open it sighs the window
appropriately and we're good to go let
me save this here because I'm going to
come back to this later want to give it
a name notice I've selected OS 10 build
let's call it RB demo then I'll actually
build a double clickable application and
it nicely opens the finder up and shows
me where I'd put it or did it put it
let's put it on the desktop ok let me do
one more thing here let's run this again
let's open that fire movie notice this
while I'm moving my mouse around the
fire burns if I stop the mouse the fire
kind of sputters and it's not getting
events here so there and if I can do the
same thing if I go back and open the
bouncing sprite movie while I'm moving
my mouse around events are getting
processed everything's hunky-dory when I
stop I get this jerkiness i discovered
purely by chance a real easy workaround
if i grab this timer tool plump it down
there give it say a 33 millisecond
period now let's try running it again
fire movie burn fun so simple little
Kluge there to make sure that events are
sent to the movie and we can now now
we're happy ok so that's real basic and
now i want to bring Keith up here to
show us talk to us about visual basics
ok I think most people have heard of
visual basic and what we want to do
today is just do a simple application
that opens the movie and plays that
movie so as the slide says it's a rapid
application development this is kind of
interesting I just did a little search
on the web and found out that it is
pretty much the biggest development
environment used on windows today the
latest version is visual basic.net and
that'll be the one I'll be using a lot
of people are still using visual basic 6
which is still pretty powerful what
we're going to do is show how easy it is
to hook into several the activex
controls and those controls there's
three of them that we'll look at and
talk about we're going to use one and
the one we're going to use this from
Skylark activex controls or just calm
objects and if you're familiar with
development on excuse me windows they're
used throughout a lot of the development
they're very easy to add to visual basic
a little bit harder to use in C++ and C
but visual basic you basically drag them
over and you can double-click and hook
them up the ones available activex
controls for quicktime you get one with
apple computer and that's installed
automatically with quicktime there is
one from Scylla skylight from from
Skylark associates and the other one is
the qtvr control x activex control and
these advocate that last will tell you
where to get these
okay i want to show you a little demo so
the first thing I'm going to do is bring
up the visual studio.net environment
here and we're going to create a new
application except that is waiting to
install some stuff here ok so I'll come
over here and just a new project and
we're going to select windows
application
what I happen here it'll create a basic
application with one form we could
actually run this in this form would
come up nothing would happen with it so
what you do over here the first thing we
want to do is if you look over in this
far left you'll see all the controls
these are activex controls and the first
thing I want to do is I'm going to I'm
going to add a menu to mind and add a
couple items to them all at a open
looked a bit earning my menu
okay I've had a few items with these
activex controls you over in the far
left you'll notice that you have a bunch
of them from doing checkboxes radio
buttons and you basically just drag them
over sometimes you don't have activex
controls these are the basic ones that
come with it that you will have to
actually add to this list so you can
drag it over first and to do that is a
right mouse button click and then you
would go over to what's that thing just
disappear add remove items and then you
could browse to your ocx activex control
and just add it into your list once it
is in your list you just drag it over to
the forum and i'm just going to size it
for doing this unnecessary we'll do some
dynamic size one second okay so what
we've done so far we created a basic
application and a couple menus and we
drag the activex control now what we
have to do is add the code to connect
all that and open up the movie so let's
do that next so if you double click on
one of the menu items it brings you over
and I'll go back to the form itself
still them all
okay so
it's set up all these little menu items
that will call when we select that now I
have a and to save time and everything
I'm just going to copy some code here
but i'll go over the code itself
just a couple routines here to size the
movie to open a movie and bring up a
file dialog and then lastly if you
program and see you know that you have
to with this particular activex control
you need to call initialize q TM l ok
this should pretty much do it for the
code and then I just should be able to
call these functions and if we're lucky
enough everything will work so on the
first one what we want to do is call
open movie the second one with a closed
movie and these are pre clip functions
that I had set up in the last one thank
you I should have caught them it would
have divided compiled exit yeah okay so
let's take a look at a movie you saw
what Tim did before basically brings up
a file dialog we do a little bit of in
this particular thing we call we just
call new openfiledialog and put in our
types here extension we're looking for
and then we call here to show the
dialogue and after that we do a little
sanity check to make sure that we got a
good result this is the real key and
that the activex control and I can show
you what happens here will type 1 and
visual basic if you do
it won't quite do that you can see all
the functions that are available to you
and you can select those so that's a
really nice feature here and you can see
what that particular activex control
offers so what i did i just went ahead
and precooked a couple things and i set
the movie controller invisible and in
this particular one I set the Open File
dialog filename into the file an item
that should that is what takes to open
up a movie after that what we'll need to
do is the size the movie so we're
looking at the natural heights of the
movie here so I do a little calculation
and get the natural width and height of
the movie and I add the movie controller
in this particular instance we know it's
16 so I just add 16 to it I think you
probably want to do a little more work
here and to figure out if you're going
to have a controller are not have a
controller with it and down in the load
of the actual the form and the control
we're going to initialize quick time and
then when we exit we're going to just
terminate it so if i typed everything
right I'm copied we should have an
application here this is a demo version
so I come over and open open zip file
dialog I lost all my movies
okay and this particular and I'll just
grab one of these these are some of the
movie said we had before also I had set
up a close I could close it or
automatically closes whoops that wasn't
supposed to happen okay so we'll do the
fire are here whoop this is running good
huh here we go let's try that again
ok
you know why I didn't do here I didn't
sighs the movie so that was a justice
ping error okay
there we go okay you can see the amount
of work here to put support for
quicktime is fairly minimal it was
really if you look at the ax skylight
one there's only a handful aligned to do
that I think about four so adding
application support for using visual
basic and QuickTime is fairly easy ok
let's turn it back over to Tim okay
before I move on to their let me do
something fun here with this my project
from before with real basic let's hope
ok let's bj 2 are we there ok this so i
just opened the real basic project that
i had before let's go in here to build
settings let's click one check box let's
go in and give this thing a name RB demo
dot exe let's say ok let's build our
application let's quit
okay now I've got this little USB thingy
that I'm going to hook in here what I
want to do is take that exe file and
give it to Keith so if all goes well
there it will mount I'm going to copy
the windows executable on to that little
thingamajig okay i will now unmount it
Keith when i'll hook this into his USB
port and see if it runs so now if we get
a bj one
so now we're getting the file opening
dialog box select a movie and it runs if
you've ever had to port an application
for mac to windows the windows to mac i
bet it was not as easy as clicking a
checkbox copping it onto your USB dongle
and moving it to another computer so
that's that's that's really powerful
that's just fantastic okay can we go
back to slides so there's the basic
portion of our talk I want to move on to
the higher level scripting language
portion of our talk and now I want to
talk about runtime revolution of the
four environments that I'm talking about
today this is the one that you may not
be familiar with put out by a company in
Scotland called runtime revolution again
it's a rapid application development
tool this time the language is a
descendant of hyper cards language hyper
talk and they call it transcript again
we get cross-platform development
capability the IDE runs means our mac or
windows and indeed on some versions of
UNIX and you can build applications for
mac or windows and they do have built-in
support for QuickTime using a movie
player control so with let's get
straight to a demo of that so now we're
back to vga to so i will launch row
evolution this is the latest version 2.0
point one if you've used earlier
versions i highly recommend you update
to this is they've done a whole lot of
work to make this latest version real
nice aqua Mac os10 citizen so here it
opened a palette of tools similar to
what we've seen in visual basic and real
basic here's sort of an application
browser and I don't yet have an empty
window what I'm going to do is come up
here and do new main stack and I'm also
going to get my cheat sheet up here
because you didn't really think I
remembered all this stuff did you
so there's my movie window what I'm
going to do then is come over here
select my quicktime player control drag
it out again set it to the top left and
i want to pull down my properties window
on screen in theory so that's saying
that the current selected object is
player 1 i want to give that a different
name i want to call that movie player i
want to turn on the controller and I
want to again turn off the border
property because i'm going to size it to
fit the the window ok now i want to give
my movie window i'll click the window
down here and not my player up here so i
want to give it a name let's call it
movie window and i think i'm ready to
add some code now i'm going to click in
the movie window again come up here and
say edit script and it opens a script
editor window this is where I'll time I
code that's associated with the movie
window so again I want to do something
when the stack or the window first opens
and the way I do that is with on
OpenStack and notice if I hit return I
automatically get the end openstack very
nice feature remember I want to select a
file open a movie and size it
appropriately the way I select a file in
transcript is by saying answer file I
can now give it a nice prompt select a
movie file and I can tell it what type
of files I want em oo v no typos they're
excellent so when that returns it's
going to have the file name of the file
that the user selected so I want to set
the file name
of the player movie player remember I
gave it a name so I could refer to it to
it it is the result of the previous
command that Iran which is the answer
file so thats file name will now get set
as the file name of the movie player
that is say will tell it what the movie
is so let's get a file and that's open
the movie now I need to size things
appropriately set width of me remember
i'm attaching code to the movie window
so I can refer to that object as me set
the width of me to the width of and I'll
just copy play or movie player because
it will open at its natural height and
width and I will do the same for the
height and now I need to do one final
thing which is set the rectangle
occupied by the movie player control and
that rectangle is going to be 0 0 with
the movie player height the movie player
and i'm done i will click apply close
that window so that's all the code i
need to add and that was what that was a
whole seven or eight lines of code a
couple final enhancements here in the
movie window i don't want it to show the
resize box so in size and position I'll
turn off resizable and I think we're
good to go so let me first save this
case something goes wrong
desktop good let me build the
application I need to set a fuse
configuration settings here where was
that I want it on the desktop I need to
so I'm set up for Mac OS 10 application
I need to tell it what stack file and in
theory where did I put it there it is
right there and I think I'm good to go
ok so I think I can quit that it should
be in this folder there's my double
click click a little application so
there it is it's put up the file
selection dialog box I will go to my
movies folder see what it does to there
it is it resized it does it run fine so
some reason we're not getting audio here
it really does support audio ok let's
try a couple other those movies just to
make sure that it's good for all of our
media types here's our quicktime VR
movie oops it works fine let's check the
keyboard i'm going to use the arrow keys
here to pan around that works fine i'll
use the shift key to zoom in that works
fine ctrl key to zoom out everything is
fine let me do one final one try our
sprite movies bouncing sprite doesn't
want to bounce there's an issue here
with getting time for the sprite movie
and I haven't quite figured it out I've
been talking with the revolution people
and I think we've figured out how to
handle this but but just so you know
that I'm not trying to hide anything
here okay I think that's what we need to
do with revolution I could do the same
thing that I did with real basic which
is go back in and click the
check box to build a Windows application
i could have keys come back up here and
run it on as windows machine and it
would be exactly what you'd expect okay
the last thing i want to talk about a
less development environment is apple
scripts to do this is the newest of the
bunch it's put out by Apple computer
again it's a rapid application
development tool the language now is
good old apple script so whereas you're
used to having apple script control
other applications now you can have
apple script control things in the same
application this is built on the cocoa
application framework so we're looking
at mac only applications and indeed a
mac only development environment so
let's launch the demo of that i'm going
to get to applescript studio by
launching project builder which
apparently has been renamed under my
feet you'll notice i'm doing everything
you're in jaguar I don't believe that
the revolution or real basic might a
chance to play with panther yet if they
have I don't know that they've certified
their tools for Panthers so I'm doing it
on jaguar here okay project builder is
open I'm going to open a new project and
right up here at the top of the list
besides room empty project is
applescript application so I'm going to
select that let's call that Apple script
studio demo I didn't make up the name
I'll find you they've taken a lot of
heat for that I expect here's my project
window as it were and I'll reveal a few
things I've got some apples a file of
applescript it's actually currently
empty because I haven't written any
script yet i have another source this is
actually some objective-c code all it
does is initialized the applescript kit
and then say let's start the application
running we don't need to change anything
there what we do want to do first to set
up our user interface so i'll open this
nib file
and here's my I didn't seem to get a new
project here so i'm going to start over
so i said new project maybe i have one
by that name already so let's call it
food mo all right let's go back open our
nib file which is our UI i guess it
wants to give me a movie view pretend
that that was initially empty so that's
our movie window you can see that I've
got a palette of tools here and there
was a nice quicktime logo so let's drag
that over here as usual i'll put it up
at the top left just for kicks now i
want to open the info panel here i'm
actually done I that's all I'm going to
put in this window so I'll get rid of
that it shows me the attributes of my
movie view there let's go to this panel
applescript and i want to give that
movie view a name so let's call it movie
view again as in these high-level
scripting languages I'm going to refer
to things by name I'm actually not going
to attach any script to the movie view
but I will attach it to the window so
it's already got a name there so I don't
know why I'm getting this I thought I
opened a new empty project but that's
really I would have given it movie
window and what I want to do is remember
with real basic we added some code to
the open routine with revolution we
added some code to the openstack now we
want to add some codes when this window
is opened and the cocoa terminology is
when we awake from the nib nib is the
file that our resources are stored in
here and the script that we're going to
attach is already said to be
the file food mo applescript let me just
check here that I've got everything let
me go back here to its properties I
don't want it visible at launch time
that was a default and I've turned off
this deferred for various reasons okay I
think that might be all we need there
let me go back to the applescript panel
and do edit script you can see I've got
just a skeleton here and it says add my
script here so that's what I'll do so
it's an unawakened handler and the
object here is the object that the
script is attached to which is the
window so if I want to do anything to
the window I can call it the object so
again I'm going to look for oh how about
five lines of code here first i'll
define a local variable set movie view
to the movie view whose name is movie
view and it is of the object so the
window has a movie view in it the name
of that movie view is movie view so I've
set the local variable movie view to the
movie you ok if everybody's confused
wonderful that just keeps me from having
to repeat this movie view movie view of
the object all the time let us set
another local variable movie pass to
what remember what I want to put up the
file opening dialogue bog box so that
choose file could it get any easier once
that's done I want to set the movie of
what movie view right that's got a movie
associated with it to the result of
loading the movie which is movie pass so
choose file gets me back a past name I
put that into the local variable movie
pass I load the movie in that path
sign it to the movie associated with the
movie view and finally I want to show
the object which was initially invisible
so let's see what happens if we build
that who's bugging me here yes ok now
let's run it within the IDE there's my
file selection dialog box I can open a
movie and what's wrong it's the wrong
size right it's the size of the movie
view why I didn't add any code Ian to
set the size of the movie window right
let's go back to my code window all I
did was get the mood select a file
attached that movie in the file to the
movie view and make the movie window
visible I didn't do any sizing here why
didn't I do any sizing because
unfortunately there's no vocabulary
built in the applescript studio that
allows me to do that so in order to find
the natural size of the movie I need to
go beyond applescript studio and this is
actually a good segue I think we're
moving on to advance put time usage here
we have slides for a second so so far
we've seen really in how much time does
that take 45 minutes so just over 10
minutes per development environment we
see that basic movie playback is easy we
haven't talked about movie editing that
can be a bit harder some of these
environments support it automatically
some of them don't what about full
access to the QuickTime api's what if I
really want to have a real quick time
application that does something more
than just open movies and play them back
and this is a good opportunity
tunity to segue into that particular
issue let's go back to vga to please so
the problem we need to solve now is how
do I determine with an apple scripts to
do what the natural size of the movie
was a real basic runtime revolution
visual basic all gave me that
information applescript studio doesn't
so we have to go beyond it now this is
the portion where I stop typing and use
a canned project that I have so I'm
going to open one that I did earlier
let's look at the script now ignore that
for a minute everything other than that
is what we did just a second ago okay
the stuff in the that is highlighted is
our way of sizing the movie
appropriately and the key here is this
call method instruction basically call
method says all right I'm applescript
studio I'm good but I can't do
everything so go call this other method
and come back to me with whatever output
it gives you what method am i calling
I'm calling a method called controller
wrecked and I'm going to pass it a
parameter namely the movie view or the
NS movie view for those cocoa people so
somewhere out there in my application is
defined this method controller wrecked
and it's going to give me back a
rectangle and let's just briefly look at
what I do that rectangle I copy it to
some local variables I get the bounds of
the window and that I do a little bit of
math to set the size of the window
appropriately the magic number 20 here
is the size of the window title bar
because in cocoa when I size a window I
don't just give it the size of the
content region but I give it the size of
the whole window
so everybody should be happy with this
except for this magic little controller
rekt method where does that come from
what I'm going to do or what I have done
is add two files to my project called
movie cat and what they do is define
what's called a category on a Coco class
a category is a way to add methods to an
existing class without actually having
the source code for that class you can
see what I've done here i have said
there's this class out there an existing
class called NS application i want to
have this category called movie cat and
it's going to have one additional method
namely controller wrecked takes a in NS
movie view and gives me back a rectangle
let's look at how I implemented that
very easy stuff it's just using
QuickTime api's fundamentally it's
calling get movie natural bounds wrecked
on the movie the actual quicktime movie
identifier where do i get that well Coco
allows me to get to useful items the
movie controller identifier and the
quicktime movie identify you can see i'm
sending to the movie view the movie
controller method it's giving me back an
item of type movie controller and also i
send the movie method to the movie view
that gives me back an NS movie which i
then send the QT movie method 2 which
gives me back a QuickTime movie so after
all that I can get the natural bounds of
the movie I then kick it up by 16 if the
controller bar is visible and I pass
that back to whoever called me so this
is a very useful example of what do you
do when applescript studio doesn't have
the vocabulary you need very easily you
can go to objective-c add a category or
other method to some existing class and
solve your problems so let's run this
now and see if it actually works
okay so there's my file selection dialog
box let's try the fire movie so that's
sized appropriately let's try it again
see if our music video comes out the
right size bingo no problem did
everybody hear that when I hit the
spacebar to start the movie I'll do it
again I'm going to turn the volume all
the way down so I'm hitting the spacebar
to start the movie what are you here you
hear the system beat or if I hit the
arrow keys to advance it one frame
forward you also hear that that's just a
flat-out bug in Jaguars implementation
of NS movie view okay basically what's
happening is the movie the application
is saying I got a I got a button press
with somebody out there please handle it
for me it sends that event to the movie
controller saying I got a button press
would you like to handle it as you can
see the movie controller actually does
handle it right the movie does start
playing but the movie controller is
clever enough not to tell whoever called
it that it handled it so then cocoa says
nobody handled this and its default
behavior is to beep okay that's just a
flat-out bug in Jaguars and its movie
that is fixed as you will discover in
Panther so if I were running this one
Panther I wouldn't even have to talk
about this problem let me run one more
movie this time let's go for the VR
movie what's wrong with this picture
it's reversed and again the in the end
the you are the scrolling is bass
ackwards here so again this is just a
flat-out bog this time it's Who am I
going to blame it on let's blame it on
NS movie view
because that is whose bug it is again
that's been fixed the the movie classes
in Panther are much improved over our
Jaguars so these bugs will not occur
when you're running under Panther ok so
let's go back to slides so we've already
seen one way in which with Apple scripts
to do we can get access to the full
quicktime api's what about real basic I
didn't demonstrate this and actually I
should because there's a very useful
capability of real basics let me go back
to again I'm just going to pull up a
canned one here to save myself the
embarrassment of bad typing looks just
like before let's pull up our movie
window let's look at let's just run it
actually well let me first look at our
code good it's commented out wonderful
let me run this okay file opening dialog
box select a movie movie opens movie
sizes correctly now I'm going to hit the
spacebar again what happened nothing
happened the movie didn't start the
default behavior of the quicktime movie
controller is to ignore keyboard input
okay so if i want that to happen here
which i probably do i need to explicitly
turn that on so let's quit that let's go
back to this how can i explicitly turn
on the keyboard support for the movie
controller there's this magic function
called MC jus action which basically
says yo movie controller which is the
software governing the playback and the
display of the movie i want you to do
something for me we can get using real
basics the movie controller identifier
using this method i'm going to send it
the action 32 which i happen to know me
please turn on keyboard input and I'm
going to pass it the value 1 which means
turn it on and not off so if I if we're
on and I wanted it off I could pass a
zero so I'm just put that right in the
middle of my real basic code can I do
that it is real basic understand these
arbitrary functions from arbitrary
libraries out there on the system no it
doesn't but it will if I tell it so up
here above you can see let me cut this
out because I don't even know that
that's accurate I'm saying if I'm
running on carbon I'm going to tell you
that there's this function I want to
call and it's called MC do action and I
need to tell real basic two things I
need to tell it what library that
function is located in it's located in
Apple carbon multimedia and then I need
to tell real basic what the parameters
are and here I've listed them there's a
movie controller there's an action and
then a value and if I scroll over it
shows that it returns a value so once i
have told real basic what this function
is what library is located and what his
parameters are i can then call it so
let's try this let's try running that
with our new code in there select a
movie I'm going to hit the spacebar and
it starts running so with one line of
code plus the declare statement I can
get access to any API in any library on
my system let's just just check that the
arrow keys or working wonderful ok so we
saw what we do with Apple scripts to do
if we need to go beyond what's built-in
we can declare extra methods with real
basic we can declare individual API
calls and use those if we want to do
something more than we need to write a
plugin why would we ever want to do
something more than just call individual
functions well the standard mindset is
that you
quicktime but in Soviet Union quicktime
calls you that is to say sometimes it's
going to call code in my application
without my explicitly telling it to do
so this is the realm of callback
functions so for instance if I want
something to happen when a movie gets to
the end or the beginning I can install a
time-based callback function that tells
pick time when you get to the end please
execute this code in my application and
I need a drink I guess the water will do
so how would you define a callback
function in real basic I don't know that
you can possible you could but if you
want to do that I think the easiest way
is to write a plug-in this is just in a
module typically written in C that you
linked in with your real basic
application and then you can call it I
don't call it and pretty much the same
way that we called MC to action the only
difference being that you don't actually
have to declare the function and where
it is and what does parameters are if
your packaging is a plugin I'll see I've
got time so let me show you what a
plug-in looks like
let me not show you what a plugin looks
like ah here we go let me show you what
a plug-in looks like I'm going to launch
this project this should bring up
codewarrior ok this is a code warrior
project most of this code comes straight
from real basics samples the only thing
I've added there's this file external
see external dot C and we can see that i
have defined here a number of functions
MC initialize MC undo cut copy paste
clear what this tells me is that movie
control are editing cut copy paste clear
is not built into real basic if it was I
would need to do this but I can get that
capability by default by creating this
plug-in that has those functions defined
so let's just take a look at one of
those MC cut getting the movie
controller yada yada yada it's basically
calling a built in QuickTime function MC
cut it's actually taking the movie that
I cut and putting it on the scrapbook so
that if I then want to paste like and do
that and so what I've got here is just a
whole bunch of C code that that I can
then build and put it into a plug-in and
let's see if this works I don't know
that I've got this configured right
here's a prebuilt thank you very much
this is a nice application it's a full
multi-window application it's more what
you think of as an application so i can
select some stuff
cut it everything works fun so if I need
to go beyond what's built in to real
basic I can either do it individually
one at a time or i can write a plug-in
same thing would run visual basic Keith
didn't need to do this because here I'm
showing what you might have to do in
visual basic 6 if you wanted to size
your window appropriately the system
ettrick stuff is built into visual
basic.net but not in the dots not into
six so you may actually have to call an
individual can we get slide back up okay
here we go so this is the same syntax
that we saw in real basic for declaring
a an external function and this would
tell you for instance how wide the frame
is on the window so that you could size
you would do appropriately for runtime
revolution again it doesn't have the
declare functionality that I know of but
you can write a plug-in similar to what
we saw there that would give you
additional capabilities within your
application and finally we already saw
what we needed to do with Apple scripts
to do use this call method statement to
go out and call objective-c functions
okay enhancement opportunities these are
really good environments I wouldn't be
up here talking about him if I didn't
think they were worth talking about so
each one of these four will allow you to
build realize solid applications each
one of them however has some issues that
I think they could work on to make them
even better realbasic has what I call
runtime issues remember when the fire
wouldn't burn unless my mouth was moving
around and I went and I put a timer
object in the window that's a kludge
okay something ought to be fixed within
real basic so that I'm getting events
more regularly let's launch my
full-featured application okay thank you
so I've launched my let's open a file
actually I don't want to use this one
because I fixed it in this here's my
demo I'll open a movie remember we went
in and we added the code that said
please enable movie controller or enable
the keyboard input so that I can use my
keyboard to manipulate the movie and we
saw that it worked right but it only
worked because I was running it inside
the IDE using the debug mode it turns
out that if I take that same application
and double-click it in the finder and
open it up the keyboard just won't work
so there's something gone wrong there
it's probably very simple fix that they
could implement to fix that other
enhancement opportunity and this one is
fairly important so I talked about
callback functions where a QuickTime is
going to call code in your application
one of the most important callback
functions is what's called a movie
controller action filter callback
procedure just to make it even longer
than it is there the idea being that
when the movie controller does something
or is about to do something it will
notify your application giving your
application the opportunity sometimes to
cancel that or sometimes to enhance that
and in an example might be if you have a
custom button in your movie controller
bar I don't have it in any of these
sometimes you see a little downward
pointing triangle in the movie
controller bar when somebody clicks on
that the movie controller will send you
an event or an action saying the user
just clicked on the button what should I
do at that point you could drop down
your own menu or do whatever you wanted
okay so these are very useful callback
functions to define I actually went
ahead and in my real basic plug-in to
find a movie controller action filter
procedure to do this kind of stuff and I
quickly discovered one thing is that
real basic also installs
movie controller action filter procedure
and i discovered this because some of
its built-in capabilities broke the
problem being is that you only get one
of these per movie controller so when i
added mine in it basically booted real
basics and so some real basics
capabilities broke there is a way around
this and it basically it involves real
basic and we'll also see this effect
runtime revolution need to come to apple
and and talk about this issue and figure
out how we can have several of these
things running around at once visual
basic enhancement opportunities not too
many there because well it really
depends on which of these activex
controls you're using some of them are
more for more full-featured than others
one interesting thing is that remember i
talked about the declared statement
working in visual basic the same way it
works in real basics there's only one
problem which is actually a big one real
visual basic 6 you cannot use the
declared statement to access functions
to access quicktime api's that's a
pretty big limitation and it has to do
with calling sequences of what visual
basic expects and what the quicktime
library is putting out runtime
revolution again there's a few runtime
issues we saw with the fire not by
burning correctly I think they can get
those work death I already mentioned
installs a movie control action filter
procedure again a fairly important issue
that we need to work out between them
and Apple Apple scripts to do
enhancement opportunities fairly limited
vocabulary right now for handling movies
there's only about 13 properties that
with pure applescript I can get in set
we thought it was fairly easy to work
around that limitation but it would be
nicer if more and more properties were
available natively another opportunity
for them to do some work which is both
good and bad apple scripts to do
applications are cocoa applications
so they inherit any features of cocoa
classes but as we saw they also inherit
any bugs from cocoa classes and we saw
two of those that have been fixed
thankfully okay most of this I've
already talked about for those
development environments that install a
movie controller action filter procedure
they need to get together with apple and
figure out how to work around that
problem one interesting thing is I'm
begging them to please when you open a
file open it with read/write permissions
your development environment may not
support editing so you may not think
that you need to open it with write
permission but if I'm a clever
programmer i can write a plug-in to
support editing but I've got this edited
movie what do I do with it all right I'm
all dressed up and I got nowhere to go I
can't put it back into the original file
if that file has been opened with
read-only permission real basic of
course opening it as an edible file
opens it with read/write permissions
runtime revolution opens files with
read-only permission so once I've
written my plug-in to edit this movie
nicely again I've got nothing to do with
it other than to put it into some other
file the skylight activex control is
kind of a funny case because it's got
built in all these editing methods but
it opens the movie file with read
permission so why is it giving me all
these methods if I can't save it into
the file finally and most of the people
do this although again interestingly
enough skylight does not make sure that
there's a way that I can get the movie
and movie controller identifiers so that
within my plugin I can take advantage of
that okay now for some boilerplate you
hear some contact information for real
software and runtime revolution I should
mention we have representatives from
both of these companies in the audience
today so afterwards maybe they could
come up to the front
here and if you have specific questions
for them that would be wonderful here's
contact information for the activex
stuff the applescript studio stuff and
finally if this was not enough detail
for you there's been a very nice series
of magazine articles in Mac tech
magazine starting last December and
extending out into the future discussing
these various environments so if you
want the gory gory details I highly
recommend picking up these magazines and
there's some documentation on quicktime
not generally relevant to what i just
talked about and today on going for the
rest of the day are the QuickTime labs
downstairs in the Sacramento room if you
want to sit down and talk to some quick
time engineers or some really good
content creation people i highly
recommend you stop down there and
there's me Keith Guillermo and we have a
little bit of time to take questions