ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Control the position of video using scrollbar

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
zhengyuanyi27 Posted - Nov 17 2019 : 03:48:11
In order to use a scrollbar to control the progress when playing an avi video (In another words, I want to drag the button of the scrollbar to control the position of the video), I used the following code to open an AVI file and set the max of scrollbar to the max frame number of the video.

with ImageEnVect2.IO.DShowParams do
              begin
                  if State = gsRunning then
                  begin
                      Stop;
                      Disconnect;
                  end;
                    FileInput:=filepath;
                    EnableSampleGrabber := true;
                    RenderAudio := true;
                    Connect;
                    if Show_Position_By_Frame then
                    ImageEnVect2.IO.DShowParams.TimeFormat := tfFrame;
                    Position := 0;
                    Pause; 
                    ImageEnVect2.IO.DShowParams.Run;

                 TotalFrames:=0;
                 TotalFrames:=ImageEnVect2.IO.OpenMediaFile(FilePath);
                 Scrollbar1.Max:=TotalFrames;

              end;

And I wrote the following code for the onChange event of the scrollbar.

procedure TForm1.ScrollBar1Change(Sender: TObject);
begin
    CurrentFrameNo:=Scrollbar1.Position;
    caption:=inttostr(CurrentFrameNo);
    ImageEnvect2.IO.DShowParams.Pause;
    ImageEnvect2.IO.LoadFromMediaFile(CurrentFrameNo);
end;

The above code works well (I mean the frame stops at the frame of scrollbar's position), but when I add one more code to the event ( ImageEnvect2.IO.DShowParams.Run; ), it seems the video doesn't play the video from where the video stops. I mean it seems that it doesn't play the video from the position the scrollbar's position. It seems the position of the scrollbar is different from the position the video stops. Could somebody tell me what's wrong? Thanks!!

procedure TForm1.ScrollBar1Change(Sender: TObject);
begin
    CurrentFrameNo:=Scrollbar1.Position;
    caption:=inttostr(CurrentFrameNo);
    ImageEnvect2.IO.DShowParams.Pause;
    ImageEnvect2.IO.LoadFromMediaFile(CurrentFrameNo);

    ImageEnvect2.IO.DShowParams.Run;  
end;
4   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Jan 01 2020 : 17:28:53
Actually the DShowParams.Position should be the current time format, e.g. if it's set to tfFrame, those values should be frame values.

Nigel
Xequte Software
www.imageen.com
zhengyuanyi27 Posted - Dec 29 2019 : 00:41:25
Thanks for your help!
So you mean that we can't directly set the video to start to play at a given frame number unless we calculate the time position of the given frame?
xequte Posted - Nov 18 2019 : 18:51:14
Hi

Use position to specify the position to run from, e.g.

// Run video from 5 second mark
ImageEnView1.IO.DShowParams.Position := 50000000;
ImageEnView1.IO.DShowParams.Run;

Nigel
Xequte Software
www.imageen.com
zhengyuanyi27 Posted - Nov 17 2019 : 04:32:37
I found the problem is:
The codes of "ImageEnvect2.IO.LoadFromMediaFile(CurrentFrameNo);" can let Imageenvect2 to load the frame at the scrollbar's position, but when excecuting "ImageEnvect2.IO.DShowParams.Run", it resumes to the frame which it pauses, NOT from the frame number to the Scrollbar's position. For example, the video pauses at the 3rd frame and I use "ImageEnvect2.IO.LoadFromMediaFile(100)" to load the image of the 100th frame, and when aplly "ImageEnvect2.IO.DShowParams.Run", the video still starts from the 3rd frame.
Thus, the question is more simple now: How to set the video to start to play at a given frame number?
Thanks!!