[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Communicating with an event queue



Unfortunately, no, communicate does not prevent hanging: http://docs.python.org/library/subprocess.html#subprocess.Popen.communicate
It says it waits for the subprocess to terminate :/

However, that mplayer slave mode looks awesome. How big would a statically compiled mplayer executable be? The windows download, with smplayer gui is 12.5 MB. Or should I create an mplayer backend that checks if mplayer has been installed?

-Tyler

On Thu, Jun 18, 2009 at 3:28 PM, René Dudfield <renesd@xxxxxxxxx> wrote:
Hi,

you can send key events, but it is very platform specific.  There
might be a xplatform python package out there somewhere to send key
events... but I'm not sure.  Maybe it wouldn't be too hard to make a
win/mac/X module yourself if one doesn't exist.

Perhaps mplayer with slave mode would be a good one to start with?
Here is the page which describes it's slave mode:
http://web.njit.edu/all_topics/Prog_Lang_Docs/html/mplayer/#slave

I'm sure you've noticed, but using communicate with subprocess can
prevent hanging - compared to using stdin/stdout directly.


cu,

On Fri, Jun 19, 2009 at 3:44 AM, Tyler Laing<trinioler@xxxxxxxxx> wrote:
> Well, the movie module will use different back ends. One back end is nearing
> alpha testing, the wrapper around ffmpeg. If that back end fails to load,
> then we want to load in a wrapper around a video player that will be
> distributed with pygame, and I'm trying to figure what needs to be done to
> get that working, and whether or not I'll need to customize its code myself.
> The wrapper would create a sub-process of the movie player, playing the
> video file given. When I communicate with the subprocess via a pipe through
> STDIN, it should theoretically be controllable.  I'm just wondering if
> there's a way, from string input to stdin, to cause SDL to fire a keyboard
> event? I don't think there is, but I thought I'd double-check that. Its
> better to take the simple and robust way, if it exists, rather than
> customizing a program for the needs of the movie module, which it looks like
> I'll have to do.
>
> -Tyler
>
> On Thu, Jun 18, 2009 at 10:19 AM, NBarnes <nbarnes@xxxxxxxxx> wrote:
>>
>> Tyler Laing<trinioler@xxxxxxxxx> wrote:
>>
>> > For the movie module, I need to be able to communicate with a process
>> > programmatically.
>> >
>> > The video player in discussion is ffplay(because its the smallest), and
>> > it
>> > has an internal event loop around the SDL event loop. When I use
>> > subprocess.Popen to open up the video player running a file, with the
>> > PIPE
>> > arguments to all std*'s, only the window spawned responds to commands
>> > from
>> > the keyboard, indicating that the event loop doesn't listen on stdin.
>> >
>> > Is there a way to cause events to be pushed onto the process's internal
>> > event loop?
>>
>> I'm not sure what the question is?  I may just be missing data due to
>> unfamiliarity with the structure in question.  Shouldn't you, as the
>> developer, be able to insert a method into the movie subsystem wrapper
>> object that takes a command and places it in queue to be processed by
>> the subprocess' loop?
>
>
>
> --
> Visit my blog at http://oddco.ca/zeroth/zblog
>



--
Visit my blog at http://oddco.ca/zeroth/zblog