I've been trying to understand this, but it seems I can't get the hang of it... sometimes it just hangs (WriteProgramData freezes?!) and I have to close the console window to get rest of the strings from mplayer. :S I know I must somehow read the feedback and not send mplayer more data than it wants.
If you want to test just get the mplayer files, which for example is included in this player:
http://smplayer.sourceforge.net/
Code: Select all
movie$ = "C:\Downloads\Californication\Californication.S01E01.avi";OpenFileRequester("","","",0)
If movie$
handle = RunProgram("C:\Program Files\SMPlayer\mplayer\mplayer.exe","-cache 1192 -","",#PB_Program_Open|#PB_Program_Write|#PB_Program_Read)
ReadFile(0,movie$)
*buffer = AllocateMemory(1192000)
While Not Eof(0) And ProgramRunning(handle)
If AvailableProgramOutput(handle)
result$ = Trim(ReadProgramString(handle))
Debug result$
If LCase(Left(result$,Len("Cache fill"))) = "cache fill" Or Left(result$,2) = "A:"
dataRead = ReadData(0,*buffer,1192000)
WriteProgramData(handle,*buffer,dataRead)
Debug "read"
EndIf
EndIf
;Debug "read"
Delay(100)
Wend
Debug "closed"
EndIf