Quicktime com automation - how do I call it?

D

Daniel Greig

Hi all,

I'm playing around with Windows Automation with the aim of processing
some quicktime movies via ruby. I've played with the WIN32OLE object to
open internet explorer (following the chapter in the pick axe) but I'm
having trouble finding some resources on how to use the Quicktime
windows library (the apple developer site has some VB examples but
nothing rubyish).

anyone know how to make this work:
qt = WIN32OLE.new('Quicktime.Application')

Or am I heading the wrong way here?

thanks,
Dan
 
P

Patrick Spence

Daniel said:
Hi all,

I'm playing around with Windows Automation with the aim of processing
some quicktime movies via ruby. I've played with the WIN32OLE object to
open internet explorer (following the chapter in the pick axe) but I'm
having trouble finding some resources on how to use the Quicktime
windows library (the apple developer site has some VB examples but
nothing rubyish).

anyone know how to make this work:
qt = WIN32OLE.new('Quicktime.Application')

Or am I heading the wrong way here?

thanks,
Dan

#-- this will fire it up and display it
qt = WIN32OLE.new("quicktimeplayerlib.quicktimeplayerapp")

#-- you guessed it, this shuts it down
qt.quit()

I'll let you fill-in the space between. I'd be interested to see what
you come up with.
 
P

Patrick Spence

Patrick said:
#-- this will fire it up and display it
qt = WIN32OLE.new("quicktimeplayerlib.quicktimeplayerapp")

#-- you guessed it, this shuts it down
qt.quit()

I'll let you fill-in the space between. I'd be interested to see what
you come up with.

Actually, I've able to cobble-up a bit more code, but it's at work. I'll
try to post it tomorrow. However, I'm still interested in whatever
someone else comes up with. This type of thing really piques my
interest!
 
D

Daniel Greig

Patrick said:
Actually, I've able to cobble-up a bit more code, but it's at work. I'll
try to post it tomorrow. However, I'm still interested in whatever
someone else comes up with. This type of thing really piques my
interest!

My interest is piqued too! Although, so far I've only got as far as your
snippet (which is to say that I have quicktime opening and closing... a
long way from being useful!).

I've snooped around WIN32OLE.new("QuickTime.QuickTime") and
WIN32OLE.new("QuickTimePlayerLib.QuickTimePlayerApp") and whilst it
looks promising, I'm struggling to work out the arguments that are
required to get the various methods working.

Anyway, I stil haven't been able to find any decent references for the
quicktime library - I'm not even sure what I'm looking for. If you can
post the extra code you mentioned and any references that you have come
across I'll let you know how it goes. I still haven't been able to find
the right references on the apple developer site - I'm sure it's there
somewhere, I've probably eve looked at it a few times, but I'm starting
to feel stupid!

Dan
 
P

Patrick Spence

Daniel said:
Anyway, I stil haven't been able to find any decent references for the
quicktime library - I'm not even sure what I'm looking for. If you can
post the extra code you mentioned and any references that you have come
across I'll let you know how it goes. I still haven't been able to find
the right references on the apple developer site - I'm sure it's there
somewhere, I've probably eve looked at it a few times, but I'm starting
to feel stupid!

Dan

Unfortunately, there's not much available concerning the Quicktime
object model. I find that rather surprizing. What I managed to figure
out was by snooping thru the object browser in a VB6 app that I threw
together.

You may have to change the path of where the sample.mov file is located.
Other than that, this works.

#--
#-- play a Quicktime movie
#--

#-- when this line is executed, Quicktime should be visible
qtApp = WIN32OLE.new("quicktimeplayerlib.quicktimeplayerapp")

#-- get a reference to the first player
qtPlayer = qtApp.players.item(1)

#-- open and play the movie
qtPlayer.openurl("c:\\program files\\quicktime\\sample.mov")
qtPlayer.qtcontrol.movie.play()

qtApp = nil
qtPlayer = nil
 
D

Daniel Greig

For anyone interested - the quicktime api is a mysterious and magical
thing...

Below is a snippet that will open quicktime, select the middle frame of
a movie, set it as the poster frame and then export it as an image. Yes,
there are probably much easier ways to do this (there's a copyFrame
function for example), but this works.

The only problem I have is that it opens the quicktime player and makes
it visible (player.visible= false does nothing). It also seems that it
should be possible to achieve the same thing using the
"QTOControl.QTControl" object, but setting the movie URL using that
object doesn't work - anyone know why (I'm fairly sure I've seen it
crash ruby as well)?

======== This doesn't work =======
require 'win32ole'

qt = WIN32OLE.new("QTOControl.QTControl")
qt = WIN32OLE.new("QTOControl.QTControl")
qt.URL = "C:\\temp\\fire.mov"
puts qt.Movie

========= This does work ========

require 'win32ole'

qtlib = WIN32OLE.new("QuickTimePlayerLib.QuickTimePlayerApp")

#get a player and open a movie
player = qtlib.Players(1)
player.visible = false #this line doesn't work...
player.OpenURL('C:\temp\source.mov')

#get the controller
control = player.QTControl

#get the movie and stop it - I don't even want to see it let alone play
it....
movie = control.Movie
movie.stop

#get the quicktime component and add an exporter
qt = control.Quicktime
qt.Exporters.Add()
exporter = qt.Exporters(1)
exporter.TypeName = "bmp";

#set the poster frame and go there (although you could really just go
there)
mid_frame = movie.Duration/2
movie.PosterTime = mid_frame
movie.ShowPoster

#do the export...
exporter.SetDataSource(movie)
exporter.DestinationFileName = "C:\\temp\\whatever.bmp"
exporter.BeginExport

#bye bye player
player.close

puts "consider it exported..."
 
P

Patrick Spence

Daniel said:
For anyone interested - the quicktime api is a mysterious and magical
thing...
<snip>
You got that right! I don't think I've seen such a poorly documented API
as this one.
======== This doesn't work =======
<snip>
I'm glad I'm not only one that's run it these problems. What's really
strange is that I threw together some JavaScript code that made sense
and actually worked as expected. With Ruby, it's a crap-shoot at best.

Thanks for the code!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top