Python help: Sending a "play" command to quicktime, or playing amovie in python

V

Varnon Varnon

I'm sure this is a simple problem, or at least I hope it is, but I'm
not an experience programer and the solution eludes me.

My realm of study is the behavioral sciences. I want to write a
program to help me record data from movie files.
Currently I have a program that can record the time of a keystroke so
that I can use that to obtain frequency, duration and other temporal
characteristics of the behaviors in my movies.

What I really want, is a way to start playing the movie. Right now I
have to play the movie, then switch to my program. I would love it if
it were possible for me to have my program send a message to quicktime
that says "play." Or any other work around really. If python could
play the movie, that would work just as well.

I'm using a mac btw.

Any suggestions?
 
C

Chris Rebert

I'm sure this is a simple problem, or at least I hope it is, but I'm
not an experience programer and the solution eludes me.

My realm of study is the behavioral sciences. I want to write a
program to help me record data from movie files.
Currently I have a program that can record the time of a keystroke so
that I can use that to obtain frequency, duration and other temporal
characteristics of the behaviors in my movies.

What I really want, is a way to start playing the movie. Right now I
have to play the movie, then switch to my program. I would love it if
it were possible for me to have my program send a message to quicktime
that says "play." Or any other work around really. If python could
play the movie, that would work just as well.

I'm using a mac btw.

Any suggestions?

import subprocess
subprocess.Popen(["open", "path/to/the/movie.file"])

Docs for the subprocess module: http://docs.python.org/library/subprocess.html
For information on the Mac OS X "open" command, `man open` from Terminal.

Cheers,
Chris
 
T

Terry Reedy

Chris said:
I'm sure this is a simple problem, or at least I hope it is, but I'm
not an experience programer and the solution eludes me.

My realm of study is the behavioral sciences. I want to write a
program to help me record data from movie files.
Currently I have a program that can record the time of a keystroke so
that I can use that to obtain frequency, duration and other temporal
characteristics of the behaviors in my movies.

What I really want, is a way to start playing the movie. Right now I
have to play the movie, then switch to my program. I would love it if
it were possible for me to have my program send a message to quicktime
that says "play." Or any other work around really. If python could
play the movie, that would work just as well.

I'm using a mac btw.

Any suggestions?

import subprocess
subprocess.Popen(["open", "path/to/the/movie.file"])

Docs for the subprocess module: http://docs.python.org/library/subprocess.html
For information on the Mac OS X "open" command, `man open` from Terminal.

Or, for more control, look at pygame or other Python game frameworks.
 
C

Chris Varnon

Thanks, That works wonderfuly. Once I set quicktimes preferences to
"play on open" it opens and plays the movie exactly like I want.
But now I need a line of code to bring python to the front again so it
can read my input. Any more suggestions?

I'm sure this is a simple problem, or at least I hope it is, but I'm
not an experience programer and the solution eludes me.

My realm of study is the behavioral sciences. I want to write a
program to help me record data from movie files.
Currently I have a program that can record the time of a keystroke so
that I can use that to obtain frequency, duration and other temporal
characteristics of the behaviors in my movies.

What I really want, is a way to start playing the movie. Right now I
have to play the movie, then switch to my program. I would love it if
it were possible for me to have my program send a message to quicktime
that says "play." Or any other work around really. If python could
play the movie, that would work just as well.

I'm using a mac btw.

Any suggestions?

import subprocess
subprocess.Popen(["open", "path/to/the/movie.file"])

Docs for the subprocess module: http://docs.python.org/library/subprocess.html
For information on the Mac OS X "open" command, `man open` from Terminal.

Cheers,
Chris
 
C

Chris Rebert

I'm sure this is a simple problem, or at least I hope it is, but I'm
not an experience programer and the solution eludes me.

My realm of study is the behavioral sciences. I want to write a
program to help me record data from movie files.
Currently I have a program that can record the time of a keystroke so
that I can use that to obtain frequency, duration and other temporal
characteristics of the behaviors in my movies.

What I really want, is a way to start playing the movie. Right now I
have to play the movie, then switch to my program. I would love it if
it were possible for me to have my program send a message to quicktime
that says "play." Or any other work around really. If python could
play the movie, that would work just as well.

I'm using a mac btw.

Any suggestions?

import subprocess
subprocess.Popen(["open", "path/to/the/movie.file"])

Docs for the subprocess module: http://docs.python.org/library/subprocess.html
For information on the Mac OS X "open" command, `man open` from Terminal.

Thanks, That works wonderfuly. Once I set quicktimes preferences to
"play on open" it opens and plays the movie exactly like I want.
But now I need a line of code to bring python to the front again so it
can read my input. Any more suggestions?

Add the -g option so focus isn't given to Quicktime (this is covered
in the manpage I pointed you to):

subprocess.Popen(["open", "-g", "path/to/the/movie.file"])

Also, in the future, try to avoid top-posting (see
http://en.wikipedia.org/wiki/Posting_style).

Cheers,
Chris
 
C

Chris Varnon

I'm sure this is a simple problem, or at least I hope it is, but I'm
not an experience programer and the solution eludes me.

My realm of study is the behavioral sciences. I want to write a
program to help me record data from movie files.
Currently I have a program that can record the time of a keystroke so
that I can use that to obtain frequency, duration and other temporal
characteristics of the behaviors in my movies.

What I really want, is a way to start playing the movie. Right now I
have to play the movie, then switch to my program. I would love it if
it were possible for me to have my program send a message to quicktime
that says "play." Or any other work around really. If python could
play the movie, that would work just as well.

I'm using a mac btw.

Any suggestions?

import subprocess
subprocess.Popen(["open", "path/to/the/movie.file"])

Docs for the subprocess module: http://docs.python.org/library/subprocess.html
For information on the Mac OS X "open" command, `man open` from Terminal.

Thanks, That works wonderfuly. Once I set quicktimes preferences to
"play on open" it opens and plays the movie exactly like I want.
But now I need a line of code to bring python to the front again so it
can read my input. Any more suggestions?

Add the -g option so focus isn't given to Quicktime (this is covered
in the manpage I pointed you to):

subprocess.Popen(["open", "-g", "path/to/the/movie.file"])

Also, in the future, try to avoid top-posting (see
http://en.wikipedia.org/wiki/Posting_style).

Cheers,
Chris

Wonderful. I totally missed the -g option.
I use pygame for the input handling currently. Maybe its not the most
elegant solution, but it's what I knew how to do. I just wasn't sure
how to do that one last bit.
Thanks a bunch!

Also, I typicaly don't post over email lists, so I didn't think about
the top-posting. This is the prefered method right?
Thanks again.
 

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,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top