Solved

Playing .avi files many times causes problems

Posted on 1998-05-02
3
147 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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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, f…

920 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