Solved

Playing .avi files many times causes problems

Posted on 1998-05-02
3
144 Views
Last Modified: 2010-04-06
I have an application which plays .avi files. When I get a notification that the movie has ended I want to start another movie and so on. This works well for 5-6 hours (each movie lasts approx 30 seconds) then the program locks up. The code in the OnNotify event looks something like the following

   MoviePlayer.Wait := true;
   MoviePlayer.Notify := false;

   MoviePlayer.Close;

   MoviePlayer.FileName := 'plate.avi';

   MoviePlayer.Open;

   MoviePlayer.Wait := false;
   MoviePlayer.Notify := true;

   MoviePlayer.Play;

I have displayed a bunch of stuff about the memory and heap status each time the movie ends but nothing obvious shows up (I accept this may be due to my lack of skill in interpretation).

This is the first time I've used this service so I'm unsure whether I can e-mail you my test program.

Thanks in advance.

Regards
0
Comment
Question by:p_oliver
  • 2
3 Comments
 

Author Comment

by:p_oliver
ID: 1340468
Edited text of question
0
 
LVL 4

Accepted Solution

by:
d003303 earned 150 total points
ID: 1340469
Yo,
seems that you are getting a stack overflow after this 5-6 hours. So, how does this happen ?
You hook into an event handler. This event handler is called by the component. In the handler, you change the state of the component. Then you leave the handler, and the call flow is a little bit messed up, because the notification handler returns to a different component state. This often happens in components that work asynchronously. Internally, the component works with messages, but the messages can not be read in the right order.
Long answer, short solution : post some private messages to yourself, so all messages will be in the right order.

Write a private message handler for your app, like

  TForm1 = class(TForm)
// stuff...
  public
    procedure WM_MyMessage(var Msg: TMessage); message WM_USER + 1;
// stuff...
  end;

// stuff...

procedure TForm1.MoviePlayerOnNotify(Sender: TObject);
begin

   MoviePlayer.Wait := true;
   MoviePlayer.Notify := false;

   MoviePlayer.Close;

   PostMessage(Self.Handle, WM_USER + 1, 0, 0);

end;

procedure TForm1.WM_MyMessage(var Msg: TMessage);
begin

   MoviePlayer.FileName := 'plate.avi';

   MoviePlayer.Open;

   MoviePlayer.Wait := false;
   MoviePlayer.Notify := true;

   MoviePlayer.Play;

end;


Slash/d003303
0
 

Author Comment

by:p_oliver
ID: 1340470
My apologies for the time taken to try your suggestions. I like
your thinking but unfortunately it only produced a slight
improvement - the program locked up after approx 7 hours
rather than the 5-6 hours previously.

I am experimenting further and have removed all code from
the OnNotify handler with the exception of the PostMessage.

The message handler now does all the manipulation of the
media player. I did this because it occured to me that switching
the notify condition off and on within the OnNotify handler might
be causing some nasty or recursive effect.

I greatly appreciate your input, if you have any other ideas to
suggest I would be most grateful.


0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
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…

759 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

20 Experts available now in Live!

Get 1:1 Help Now