I'm trying to make a cross-platform player written in PHP for a particular video format using mplayer.
The PHP script builds the video file and launches mplayer, while it continues to build the video file.
Sometimes the PHP script it's not fast enough and mplayer crashes because it hasn't anymore bufferized video.
So, I need to control mplayer to pause it if I need buffering.
I made a function - just for test - that tries to stop video after 5 seconds.
(Here is a list of commands: http://www.mplayerhq.hu/DOCS/tech/slave.txt) \[code\]...function OnClickButtonStart() { $mplayer = popen("mplayer -wid " . $wid . " -slave -quiet -idle " . $filename . " > /dev/null 2> /dev/null &", "w"); var_dump($mplayer); sleep(5); echo "\nPausing..."; fputs($mplayer, "pause\n"); fflush($mplayer); echo "done!\n"; return $mplayer;}... \[/code\]but, even if the output is:\[code\]resource(5) of type (stream)Pausing...done!\[/code\]the video doesn't stop!
What's wrong?
The PHP script builds the video file and launches mplayer, while it continues to build the video file.
Sometimes the PHP script it's not fast enough and mplayer crashes because it hasn't anymore bufferized video.
So, I need to control mplayer to pause it if I need buffering.
I made a function - just for test - that tries to stop video after 5 seconds.
(Here is a list of commands: http://www.mplayerhq.hu/DOCS/tech/slave.txt) \[code\]...function OnClickButtonStart() { $mplayer = popen("mplayer -wid " . $wid . " -slave -quiet -idle " . $filename . " > /dev/null 2> /dev/null &", "w"); var_dump($mplayer); sleep(5); echo "\nPausing..."; fputs($mplayer, "pause\n"); fflush($mplayer); echo "done!\n"; return $mplayer;}... \[/code\]but, even if the output is:\[code\]resource(5) of type (stream)Pausing...done!\[/code\]the video doesn't stop!
What's wrong?