[MPlayer-cygwin] Slave-mode

Sascha Sommer saschasommer at freenet.de
Thu Dec 1 12:46:14 CET 2005


On Thursday 01 December 2005 11:32, Hans-Carl Oberdalhoff wrote:
> Hello List,
>
> I'm playing around, trying to use ruby under windows to control the
> mplayer using slave-mode. And I get some problems.
>
> Here is a bit of example code:
>
> -------
>
> #Defs
> $MPlayerExe = "x:/video-projekt/mplayer/mplayer.exe"
> $VideoFile = "x:/video-projekt/video.mpg"
>
> #start mplayer
> $mplayer = IO.popen($MPlayerExe+" -slave -osdlevel 2 -quiet
> "+$VideoFile,"w+")
>
> #Read its output.
> Thread.new {
>   while true
>    $mplayer.each {|line|
>    puts "GOT "+line
>   }
>   sleep 0.1
>   end
>  }
>
> #send commands to mplayer
> puts "get time"
> $mplayer.puts "get_time_pos"
> puts "try pause"
> $mplayer.puts "pause"
>
> -------
>
> I can read mplayers output nicely, as expected. But is does not care
> about the input (commands).
> (And yes, "puts" sends a newline ;) )
> I tried things like flushing, using printf and write.
> Can someone help?
>
> While studying the problem I saw the following:
>  "echo pause | mplayer -slave video.mpg"
> does work nicely and pauses the video.
>
> But, if I use ruby (with a script containing for example 'puts "pause"')
>  "ruby script.rb | mplayer -slave video.mpg"
> nothing happens. (video plays on)
>
> What is different here?
> Btw, it does also NOT work, if I use these commandsinside an MSYS shell.
>
> Can anyone help?
> greetz,
> Hans-Carl
>

It is only a guess, but there might be a difference between dos and unix end 
of lines. I don't know what mplayer expects, though.

Sascha




More information about the MPlayer-cygwin mailing list