Solved

Playing .avi files many times causes problems

Posted on 1998-05-02
3
151 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

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…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

752 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