Thank u for your reply
But im trying to find some example that explain how to write the comnands using mplayercontrol and without mplayercontrol.
With TMplayerControl. Have a look at the supplied demo.
https://svn.code.sf.net/p/lazarus-ccr/svn/components/mplayer/examples/FullFeatured/ https://svn.code.sf.net/p/lazarus-ccr/svn/components/mplayer/examples/Simple/From the wiki link I posted...
In the examples folder, see FullFeatured\mplayerTestHarness.lpr for a full demonstration of TMPlayerControl capabilities, as well as additional functionality for querying mplayer for available commands.
Fullfeatured contains working Start, Stop, Pause.
Honestly, I recommend you just open the Fullfeatured project. It's got what you said you need, and is exactly the reason why I wrote it. If you find this project doesn't answer your questions, then please clearly specify exactly what it is you're after and I'll post some sample code.
...and without mplayercontrol.
However, if you insist on reproducing the functionality of TMplayerControl, then here are some notes:
Without TMplayerControl I would recommend exactly the same workflow that's inside TMplayerControl. The code is all there, and while sure - you can mock my commenting skills, at least I tried :-)
The issue with the code you posted in the original post is that you free TProcessUTF8. So, you need to stop to doing that.
Good example code to how to do this is inside
procedure TCustomMPlayerControl.Play;
procedure TCustomMPlayerControl.Stop;
(basically, this ensures the TProcessUTF8 is alive for the entire duration of the playing video)
Once you've stopped freeing the object, you need a mechanism for sending data to the running instance of mplayer.exe.
The example code for this is inside:
procedure TCustomMPlayerControl.SetPaused(const AValue: boolean);
which leads you to
SendMPlayerCommand('pause');(I've bolded that bit because this may be what you're trying to ask)
which leads you to
procedure TCustomMPlayerControl.SendMPlayerCommand(Cmd: string);
which has example code for injecting commands into a running TProcessUTF8, namely
FPlayerProcess.Input.Write(Cmd[1], length(Cmd));
Right, so now we're inputing commands into the running instance of mplayer, we need to start listening to the results the mplayer is giving back to us. In the TMplayerControl, we're doing this with a timer. This leads to a little of fun as there is now a disconnect between when we send the request and when we get the information back.
Finally, this brings us to:
procedure TCustomMPlayerControl.TimerEvent(Sender: TObject);
This contains the code for retrieving the data from the running instance of mplayer.exe, as well as some state management code (if mplayer.exe just told us it's paused the video as we requested earlier, then we better update the paused state flag, that sort of thing). The code for listening into the TProcessUTF8 is basically
// global variable
Private
FOutlist : TStringList;
...
FOutlist := TStringList.Create;
...
// and then inside the timer code...
if FPlayerProcess.Output.NumBytesAvailable > 0 then
begin
FOutList.LoadFromStream(FPlayerProcess.Output);
// bunch of stuff that processes the contents of the stringlist...
end;
(Disclaimer: Almost none of the above code is mine. All I did was add the FullFeatured example code and expanded the FOutList.LoadFromStream(FPlayerProcess.Output) state management processing. Re-reading this post I make it sound like I wrote it all, and that's simply not the case...)