[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1280
  • Last Modified:

DSPack playing / Controlling movie through DLL

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
AuthorwareXtras
Asked:
AuthorwareXtras
  • 8
  • 8
1 Solution
 
2266180Commented:
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
 
AuthorwareXtrasAuthor Commented:
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
 
2266180Commented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
AuthorwareXtrasAuthor Commented:
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
 
2266180Commented:
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
 
AuthorwareXtrasAuthor Commented:

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

Thanks very much.  :-)
0
 
2266180Commented:
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
 
AuthorwareXtrasAuthor Commented:
Hi

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

0
 
2266180Commented:
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
 
AuthorwareXtrasAuthor Commented:
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
 
2266180Commented:
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
 
AuthorwareXtrasAuthor Commented:
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
 
AuthorwareXtrasAuthor Commented:
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
 
2266180Commented:
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
 
AuthorwareXtrasAuthor Commented:
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
 
2266180Commented:
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 8
  • 8
Tackle projects and never again get stuck behind a technical roadblock.
Join Now