Posted by Gregory on July 01, 2007
In Reply to Playing an Album posted by Peter Howes on
June 12, 2007
: I have a list box on a form in Delphi4.0 containing the file neams for a complete (song) album. On the same form I have a media player component which I can use to play a single track. Is there available a simple code segment which I can attach to a "PlayAlbum" button that will play the songs in the list box consecutively without requiring me to click the media player after each track has finished?
Before sending command "Play" to the MediaPlayer, set property Notify to True.
When the song is finished, you will receive an OnNotify event and property Notify is again set automatically to False.
Use OnNotify event for playing next song of listbox (if there is a next song).
When you start playing the songlist (pseudo-code):
SetListboxToFirstItem; MediaPlayer1.Notify := True; PlayCurrentItemOfListbox;
The OnNotify event handler:
if not ListboxAtLastItem then begin ListboxGoToNexItem; MediaPlayer1.Notify := True; PlayCurrentItemOfListbox; end;
Hope this helps :) if not detailed enough, ask me and I try to write some _real_ code.