1. Home
  2. Computing & Technology
  3. Delphi Programming

How to detect when a TMediaPlayer stops playing

By Zarko Gajic, About.com

The Notify property resets back to False when a notify event is triggered, so in order for you to recieve further notify events, you have to set it back to True as in the code. for the MODES available, see the helpfile for MediaPlayer.Mode.

~~~~~~~~~~~~~~~~~~~~~~~~~
procedure TForm1.FormCreate(Sender: TObject) ;
begin
   MediaPlayer1.Notify := True;
   MediaPlayer1.OnNotify := NotifyProc;
end;

procedure TForm1.NotifyProc(Sender: TObject) ;
begin
   with Sender as TMediaPlayer do
   begin
     case Mode of
       mpStopped: {DO something HERE};
     end;
     //must set to true to
     //enable next-time notification
     Notify := True;
   end;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» Disable LogOff, TaskManager and ShutDown on Win NT systems (2000/XP)
« How to get the number of words in Richedit

Zarko Gajic
Guide since 1998

Zarko Gajic
Delphi Programming Guide

Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2002 Delphi Tips
  7. How to detect when a TMediaPlayer stops playing

©2009 About.com, a part of The New York Times Company.

All rights reserved.