thread focus question.

M

Mike Zupan

I wrote this simple threading app using pygame. I'm looking to load a
movie via mplayer in full screen mode and have all my events be sent
to my python app and not mplayer. When my mouse is over the python app
it handles the events but when its over the mplayer window it handles
mplayer only. I'm new to threads so if anyone has a really great
tutorial let me know. My book didn't go into great detail



import pygame
from pygame.locals import *
import thread
from time import sleep, time, ctime
import os
import sys

mplayer_loc = '/usr/local/bin/mplayer'
mplayer_args = ' -vo xv -slave '
file = '/dump/mp3s/1short.mpeg'

def loop0():
print "using mplayer which is at: ", mplayer_loc
os.system(mplayer_loc + mplayer_args + file)
while 1:
for event in pygame.event.get():
if event.type == KEYDOWN:
print "KeyDown on the MOVIE!",
event.key

def main():
pygame.init()
window = pygame.display.set_mode((600,400))
pygame.display.set_caption('testing')
#pygame.display.toggle_fullscreen()
print 'starting threads'
thread.start_new_thread(loop0, ())
while 1:
for event in pygame.event.get():
if event.type == KEYDOWN:
print "KeyDown", event.key
print 'all done at: ', ctime(time())


if __name__ == '__main__':
main()
 
A

Aahz

I wrote this simple threading app using pygame. I'm looking to load a
movie via mplayer in full screen mode and have all my events be sent
to my python app and not mplayer. When my mouse is over the python app
it handles the events but when its over the mplayer window it handles
mplayer only.

It appears that mplayer is a separate process. The only way what you
want will work would be if you can get mplayer to forward events over a
socket or something.
 

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,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top