Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to establish when MediaPlayer is finished?

Status
Not open for further replies.

doctorjellybean

Programmer
May 5, 2003
145
When MediaPlayer has completed playing a media, I need something else to happen. I tried the following code in the MediaPlayer's OnNotify Event, but nothing happens:
if (MediaPlayer1.NotifyValue = nvSuccessful) and (MediaPlayer1.Mode = mpStopped) then label1.caption:='Finished'.
Could someone please tell me what I am doing wrong.

Thank you.
 
It looks like you got to set MediaPlayer1.Notify to true for each time you do it. Before you go in and at the end of your OnNotify code if you want to repeat the notification.
 
I looked into this more. The MCI part of things (or TMediaPlayer) is pretty messed up in this respect. No one's said too much about it, but I noticed it to be pretty inconsistent myself (Mode was "mpStopped" while the file was going, and "mpPlaying" when finished). The most reliable method to determine whether a file has been stopped seems to be the one I used in the example you should have.

TMediaPlayer Notify Bug? (1)

TMediaPlayer Notify Bug? (2)

A thought echoing one of the thoughts in the links - if you were going to be very serious about playing media, it might be worth it to look to a newer interface such as the Windows Media Player interface.
 
it might be worth it to look to a newer interface such as the Windows Media Player interface

It looks like it will have to be. It appears to use an ActiveX control, and from what I remember, these controls were a hit and miss affair with earlier versions of Delphi. I will investigate this, thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top