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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Video completion event
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

egrobler

42 Posts

Posted - Mar 25 2012 :  15:22:25  Show Profile  Reply
Hello,

I am playing a video using
ImageEnView1.IO.DShowParams.FileInput := 'myvideo.wmv';

How can I be notified (callback function) that the video has finished?

Thanks & Regards
Eric

fab

1310 Posts

Posted - Mar 25 2012 :  23:08:10  Show Profile  Reply
Hello,
handle the event TImageEnView.OnDShowEvent. Example:
procedure Tfmain.ImageEnView1DShowEvent;
var
  event:integer;
begin
  while ImageEnView1.IO.DShowParams.GetEventCode(event) do
    case event of
      IEEC_COMPLETE:
        begin
        ... end of stream!
        end;
    end;
end;
Go to Top of Page

egrobler

42 Posts

Posted - Mar 26 2012 :  05:30:14  Show Profile  Reply
Hi Fabrizio, thanks for the feedback, unfortunately IEEC_COMPLETE does not seem to fire and I get an exception when trying to play the video when creating a dynamic instance.
Please see ButtonClick example below.

Thanks


procedure TForm1.Button1Click(Sender: TObject);

    procedure PlayVid(var aView : TImageEnView);
    var   event:integer;
    begin
      aView.IO.DShowParams.FileInput := 'example.wmv';
      aView.IO.DShowParams.RenderAudio := True;
      aView.IO.DShowParams.RenderVideo := True;
      aView.IO.DShowParams.Connect;
      aView.IO.DShowParams.Position := 0;
      aView.IO.DShowParams.Run;

      while aView.IO.DShowParams.GetEventCode(event) do
      begin
        case event of
          IEEC_COMPLETE:
          begin
            ShowMessage('Done');  //not fired?
          end;
         end;
       end;
    end;

    procedure PlayInstanceOnForm;
    begin
      PlayVid( ImageEnView1);  //playing dfm instance works
    end;

    procedure CreateDynamicInstanceAndPlay;
    var AImageEn :  TImageEnView;
    begin
      AImageEn := TImageEnView.Create(Self);
      AImageEn.Parent := Self;
      PlayVid( AImageEn);  //always an exception: EInvalidOp  "Invalid floating point operation"
    end;

begin
  PlayInstanceOnForm;
  CreateDynamicInstanceAndPlay;
end;
Go to Top of Page

fab

1310 Posts

Posted - Mar 26 2012 :  06:56:36  Show Profile  Reply
Hi Eric,
please handle the TImageEnView.OnDShowEvent because GetEventCode returns a valid code only inside that event.

You could write:

   procedure PlayVid(var aView : TImageEnView);
    var   event:integer;
    begin
      aView.OnDShowEvent := DShowEvent;    <<<< added this
      aView.IO.DShowParams.FileInput := 'video\DifesaDiritto1.wmv';
      aView.IO.DShowParams.RenderAudio := True;
      aView.IO.DShowParams.RenderVideo := True;
      aView.IO.DShowParams.Connect;
      aView.IO.DShowParams.Position := 0;
      aView.IO.DShowParams.Run;
    end;


...and...
procedure TForm1.DShowEvent(Sender:TObject);
var
  event:integer;
begin
  ImageEnView1.IO.DShowParams.GetEventCode(event);   // <<<< note: of course cannot be ImageEnView1 when created at runtime!!
  case event of
      IEEC_COMPLETE:
      begin
        ShowMessage('Now fired');
      end;
   end;
end;


About the exception, please set a size for the container bitmap (that is not sized automatically when TImageEnView is created at runtime). Example:

    procedure CreateDynamicInstanceAndPlay;
    var AImageEn :  TImageEnView;
    begin
      AImageEn := TImageEnView.Create(Self);
      AImageEn.Parent := Self;
      AImageEn.IEBitmap.Allocate(300, 300);   <<<< added this
      AImageEn.SetBounds(0, 0, 300, 300);      <<<< added this
      PlayVid( AImageEn); 
    end;


Go to Top of Page

egrobler

42 Posts

Posted - Mar 26 2012 :  14:15:16  Show Profile  Reply
Hi Fabrizio,

Thanks for your feedback, your suggestions works :-)

In the DShowEvent procedure I just used (Sender as TImageEnView).IO

Best Regards
Eric
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: