Solved

Playing .avi files many times causes problems

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using idhttp to login to instagram 2 89
Create Database on Android via Delphi dbExpress 3 88
Base1 Encode/Decode 3 77
Delphi: sending SMS on android platform 1 17
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…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 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

11 Experts available now in Live!

Get 1:1 Help Now