Solved

DSPack playing / Controlling movie through DLL

Posted on 2006-10-24
16
1,173 Views
Last Modified: 2010-04-05
I want to use use DSPack from with a DLL to create a video window and play back a video.  The video window should be created within another non delphi application by calling the DLL from that application.  Creating a DLL and calling it from another application is not a problem, it is just the DSPack elements I am having trouble with.

I have tried this so far:

  //create the filter graph
   FilterGraph := TFilterGraph.Create(nil);

   //I tried both these options below
  //VideoWindow := TVideoWindow.Create(nil);
   VideoWindow := TVideoWindow.CreateParented(AW.hwnd);  //AW.hwnd is the Window Handle of the application calling the DLL, so I have the handle OK

  VideoWindow.FilterGraph:= FilterGraph;
 
//Just hard coding these values at the minute until I get it working.  They will ultimately be passed as part of the DLL call
  VideoWindow.Left:=10;
  VideoWindow.Top:=10;
  VideoWindow.Width := 320;
  VideoWindow.Height := 240;
  VideoWindow.Visible:=true;

  FilterGraph.Active := true;
  //FilterGraph.ClearGraph;  
  FilterGraph.RenderFile(strFileToPlay);  
  FilterGraph.Play;

If I un-comment FilterGraph.ClearGraph I get an access violation.  if I comment it out, I don't get an access violation, but neither do I get a video window with a video playing.  When I close the application calling the DLL I get the standard "program has encountered a problem and needs to close" dialog box inviting me to imform uncle Bill!  Maybe the Video Window has not been cleanly destroyed??

Ultimately I wish to do the 'standard' things you may wish to do with a video such as play pause, stop etc as well as respond to events from the DSPack components from within the DLL

Any help appreciated.
0
Comment
Question by:AuthorwareXtras
  • 8
  • 8
16 Comments
 
LVL 28

Expert Comment

by:ciuly
ID: 17794892
you're not doing it right. you don't create the videowindow, but you query for it. and then you can try the put_woner ethod, though I never tried that. here is a demo to get you started: http://www.ciuly.com/delphi/multimedia/dspackStreamPlayer/index.html
it has a lot of unnecessary stuff for you, but it also has the player which you can use.
0
 

Author Comment

by:AuthorwareXtras
ID: 17795007
Can't get that to work.  I follow the instructions and end up wth a player.exe file but launching that gives an error and opening the dpr tells me there are components missing.
0
 
LVL 28

Expert Comment

by:ciuly
ID: 17795029
then you did not follow all the instructions. make sure the directory structure is as explained (even if you have dspack installed: it doesn't matter, just extract from the original zip in another directory, they will not collide).
also, I see now that it's not logical for the folowing to be done from those instructions: put a test.mpg file in "the merger" directory. you can download the sample from my site if you don't have one.
0
 

Author Comment

by:AuthorwareXtras
ID: 17795131
I did follow the instructions.

It now works after I put the video in plave in that I can run the exe and see the video.  I am failing to see how this helps me though as I open the ThePlayer.dpr file and I get the dialog telling me that I am missing TStreamFilter, TMyFilterGraph and TFileStreamWrapper
0
 
LVL 28

Expert Comment

by:ciuly
ID: 17795189
that is because the components are not isntalled ;) that is a command line build process that does not make use of installed components. it's actually retty nice when you want to try something and don't want to install it in the IDE.

anyway, getting back to your porblem: what will help you is the actual player. you can see the code how the player is created and how to work with the videowindow which is your actuall problem. then, where I do:
      FilterGraph.QueryInterface(IVideoWindow, VideoWindow);
      if VideoWindow<>nil then
      begin
        VideoWindow.get_Visible(isVideoVisible);
        VideoWindow.put_Caption('My Async Player');
        VideoWindow.put_Left(0);
        VideoWindow.put_Top(0);
        VideoWindow.put_WindowStyle(WS_DLGFRAME);
        VideoWindow.put_AutoShow(true);
      end;

you also add the line
VideWindow.put_Owner(AW.hwnd);// as I said, I never tried this but makes sens.

for testing purposes, you can use the already existing form2 from the package (which btw is not used. I see that I forgot it there. the demo is a strip of a fully functional player and form2 is used for MCI playback if I recall correctly).
anyway, I'll do some modification for you if you can't get it by yourself, but only after about 30-40 min as I have something that I need to finish first.
0
 

Author Comment

by:AuthorwareXtras
ID: 17795512

I think I am missing something here, so I will wait for your example.

Thanks very much.  :-)
0
 
LVL 28

Expert Comment

by:ciuly
ID: 17799419
sorry for the late response. I had some things to take care of and of course I forgot a very small line from the code and it took me a few hours until I realised why it didn't work :D (forgot to render the file :)) )

so, I made a stripped down project: only a player that will make the videowindow appear on a different window (form2 in this case) available on that same page I have given you (direct project link: http://www.ciuly.com/delphi/multimedia/dspackStreamPlayer/index.html)
0
 

Author Comment

by:AuthorwareXtras
ID: 17801658
Hi

Source - Player Only links to the same page and not the source:  http://www.ciuly.com/delphi/multimedia/dspackStreamPlayer/index.html

0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 28

Accepted Solution

by:
ciuly earned 500 total points
ID: 17801675
true. sorry. was kind of late last night and didn't pay attention to what actually happened there as I've doen this a lot of times.
I corrected the link: http://www.ciuly.com/delphi/multimedia/dspackStreamPlayer/dspack_player_only.zip
0
 

Author Comment

by:AuthorwareXtras
ID: 17802384
I have that working now thanks very much and will accept that as the answer.  I just have a couple of questions on this solution:

1. Is there anything that can be returned to the calling application (handle, object pointer?) so that it can be used in subsequent function calls to work on the movie window, so for example, if the application calls the DLL with PlayMovie(strFilename, intLeft, intTop) can the function return a handle or something, so that subsequently a second function such as MoviePause (Handle, blnPause) //true or false can be used??

2. The application calling the DLL gives an error on exit currently.  I assume this is related to the fact the movie window has not been closed gracefully.  This probably therefore refers to the previous question in that I will need a function like CloseMovie(handle)  ??

3. The movie appears and plays, but seems to 'jump' to it's required location as opposed to appearing there.  Any idea what may be causing that.

Thanks for your help once more.
0
 
LVL 28

Expert Comment

by:ciuly
ID: 17802462
1. sure. you return a reference to filtergraph like function PlayMovie(strFilename MAKE this pchar or include the sharemem usnit for string. see teh comment when creating a dll, intLeft, intTop):TFilterGraph;

2. true. you will have to cal FilterGraph.ClearGraph; when finishing

3. try the following. seems to work ok:
      FilterGraph.RenderFile(filename);
      FilterGraph.QueryInterface(IVideoWindow, VideoWindow);
      form2.show;
      if VideoWindow<>nil then
        videoWindow.put_Owner(form2.Handle);
      FilterGraph.Play;

      if VideoWindow<>nil then
      begin
        VideoWindow.get_Visible(isVideoVisible);

I didn't see that jump before either, but this might fix it in case it was just too fast for my eyes :)
0
 

Author Comment

by:AuthorwareXtras
ID: 17802543
Thanks I will give it all a try....The maybe don't see the jump because the window I am putting the video on to is there already instead of form2.show here.....
0
 

Author Comment

by:AuthorwareXtras
ID: 17802806
I almost have it!  I am trying the following:

Function EraseMovie(FilterGraph:TFilterGraph):Boolean;stdcall;
begin
  try
     FilterGraph.Stop;
     FilterGraph.ClearGraph;
     //FilterGraph.Destroy;
     Result:= true;
     except on E:Exception do
        begin
        showmessage(E.Message);
        result:=false;
        end;
     end;
end;

The movie window erases, but the application throws an exception still on exit....any ideas?
0
 
LVL 28

Expert Comment

by:ciuly
ID: 17803024
use FilterGraph.Free; not destroy if you want to distroy the filtergraph, though only do that if you manually created it and not placed it on a form. if you placed it on a form, then leave it for the form to distroy it (you can also reuse it, since you cleared it ;) )

but what is the exception?
0
 

Author Comment

by:AuthorwareXtras
ID: 17803110
You will notice that Destroy is commented out.  I tried it as a last resort after trying free.  Using FilterGraph.Free hangs the application.

using:

     FilterGraph.Stop;
     FilterGraph.ClearGraph;

Removes the window but when the application is closed it shows the windows "Program has encountered a problem and needs to close" dialog inviting me to tell uncle Bill about it.  This is what was happening before I was removing the window and I assumed it was because the window was still present, but that seems not to be the case.


0
 
LVL 28

Expert Comment

by:ciuly
ID: 17803353
the problem could lies somewhere else. can you make a small demo with dll and how you are using everything that reproduces this behaviour? so that I can find what you migt be doing wrong.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now