Reputation: 1
I have built a mediaplayer application based on the PlayWin demo that comes with DSPack. I have built this in Delphi 10.4 Sydney. The primary file type I am focussing on is *.mp4. All this is working fine.
I would like to provide the capability to move to the middle of the currently plying video and continue playing to the end of the video.
I have searched extensively on StackOverflow and attempted any solutions that appear correct. Nothing has worked.
My current attempt is:
procedure TMediaPlayer.btnMoveToMidVideoClick(Sender: TObject);
Var
sgBefore: String;
sgAfter: String;
MediaSeeking: IMediaSeeking;
Start: Int64;
Stop: Int64;
begin
FilterGraph.Active := true;
VideoWindow.FilterGraph:= FilterGraph;
FilterGraph.RenderFile('S:\iTube Studio Downloaded\6.5 HP Greyhound Engine\6_5HP_Best Way To Clean a Honda Style Carburetor - Vide0.mp4');
FilterGraph.QueryInterface(IMediaSeeking, MediaSeeking);
Start := 1200519 div 2;
Stop := 1200519;
MediaSeeking.SetPositions(Start, AM_SEEKING_AbsolutePositioning, Stop, AM_SEEKING_AbsolutePositioning);
FilterGraph.Play;
end;
I HAVE NO IDEA WHERE TO GET THE START AND STOP VALUES FROM.
Can anyone figure out how to move to the middle of a currently playing video?
Dick Maley
Thank you in advance.
Upvotes: 0
Views: 279
Reputation: 1
I thank you all for your ideas.
It can be done, Here is the code that achieved it.
Procedure TMediaPlayer.actVideoHalfWayExecute(Sender: TObject);
Var
inThumbX: Integer;
inThumbY: Integer;
R: TRect;
Begin
FillChar(R, 0, Sizeof(R));
tbDSTrackBar.Perform(TBM_GETTHUMBRECT, 0, lparam(@r));
inThumbX := (r.Left + r.Right) Div 2;
inThumbY := (r.Top + r.Bottom) Div 2;
tbDSTrackBar.MouseDown(mbLeft, [], inThumbX, inThumbY);
tbDSTrackBar.Position := tbDSTrackBar.max Div 2;
Application.processmessages();
inThumbX := tbDSTrackBar.Width Div 2;
tbDSTrackBar.MouseUp(mbLeft, [], inThumbX, inThumbY);
Application.processmessages();
End;
However, I cheated. I modified TDSTrackBar in DSPack.pas from
protected
{@exclude}
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
{@exclude}
procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
{@exclude}
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
{@exclude}
procedure Timer; dynamic;
To
public
{@exclude}
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
{@exclude}
procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
{@exclude}
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
{@exclude}
procedure Timer; dynamic;
My objective was to move to the halfway point in the video and trackbar, however this code can be used to move any anywhere in the video and trackbar.
Thank you
Dick Maley
Upvotes: 0