Solved

DSPack playing / Controlling movie through DLL

Posted on 2006-10-24
16
1,177 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:2266180
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:2266180
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:2266180
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:2266180
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 28

Accepted Solution

by:
2266180 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:2266180
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:2266180
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:2266180
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

919 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

21 Experts available now in Live!

Get 1:1 Help Now