getting input from another program
BlitzMax Forums/BlitzMax Programming/getting input from another program| 
 | ||
| I have some working code to start and control an external player program, but besides sending commands like pause, mute, seek and so on, I would like to receive input from it as well, such as position, lengths and so on. The following code is something I put together by taking out some of the code from my control program. Its not complete, but it should demonstrate where my problem is and what I am after. 
Type TPlayer
	Global pipe:TPipeStream
	Field process:TProcess
	Field stream:TStream
	Function createPlayer:TPlayer(hwnd:Long)
		Local this:TPlayer=New TPlayer
		Local cmd:String=PlayerPath+" dvd://1 -dvd-device "+VirtDrivePath+" -slave -colorkey 0x0A0A0A -vf scale="+scrX+":"+scrY+" -noaspect -wid "+hwnd
		this.process=TProcess.Create(cmd,0)
		this.stream=OpenStream(cmd)
		Return this
	End Function
	Method Mute()
		pipe=process.pipe
		pipe.WriteLine( "mute"+Chr(10) )	' MUTE
	End Method
	Method Seek(ff:Int)
		pipe=process.pipe
		pipe.WriteLine( "seek "+ff+Chr(10) )	' FORWARD ff SECONDS
	End Method
End Type
Rem
mute [value]
    Toggle sound output muting or set it to [value] when [value] >= 0
    (1 == on, 0 == off).
seek <value> [type]
    Seek to some place in the movie.
        0 is a relative seek of +/- <value> seconds (default).
        1 is a seek to <value> % in the movie.
        2 is a seek to an absolute position of <value> seconds.
get_time_length
    Print out the length of the current file in seconds.
get_time_pos
    Print out the current position in the file in seconds, as float.
EndRem
As you can see, if I need to send a command to the external player, I use the WriteLine command of the process module. This works just fine. But if you look at the text between the Rem/EndRem statements, you will see what the documentation tells me about getting output from the player. And this is where I am stuck. I have no idea how I would go about getting this output into my program. Does anyone have any ideas how to get the values of get_time_length and get_time_pos? Here is a link to the complete documentation text: http://www.mplayerhq.hu/DOCS/tech/slave.txt | 
| 
 | ||
| Method ReadLine$()	'nonblocking - returns empty string if no data available yourString = pipe.ReadLine$() send your command first via pipe.WriteLine and get the result with pipe.ReadLine imagine it that your pipe has two tubes, one pointing to stdin and one to stdout | 
| 
 | ||
| I had tried using ReadLine$() but for some reason unknown not in connection with the WriteLine$(), but just testing a bit, it seem to be in the right direction. Thanks. |