Posted by webmaster Guido on February 08, 2007
In Reply to Delphi MP3 Player posted by Graham J Hadlington
p12555 on
February 06, 2007
:
Has anyone created a mp3 player in Delphi? If so, is this for sale?
Don't buy one, roll your own MP3 player :)
It's very easy with Delphi's TMediaPlayer component, that allows you to add audio and/or video
clips to your application. It opens a media device and plays, stops, pauses, etc., the specified audio
and/or video file.
Here's the shortest example on how to play an MP3 file:
procedure TForm1.Button1Click(Sender: TObject); begin MediaPlayer1.Close; MediaPlayer1.FileName := 'c:\music\test.mp3'; MediaPlayer1.Open; end;
And there's your MP3 player in its most basic form, only 3 lines of code!
Over the next week, we're publishing a more detailed tutorial on programming your own MP3 player. To start with, we'll cover the possibilities of TMediaPlayer; next we'll add some whistles and bells like: selecting a file from a list, displaying the ID3 tag, displaying a progress bar, and so on...
The tutorial starts on this page: MP3 Player, part 1
A few programming tips, for those of you that are to impatient ;-)
procedure TForm1.Button1Click(Sender: TObject); begin MediaPlayer1.Close; MediaPlayer1.FileName := 'c:\music\test.mp3'; MediaPlayer1.Open; MediaPlayer1.Play; end;
MediaPlayer1.FileName := ExtractFileDir(Application.ExeName) + '\test.mp3';
Guido, DelphiLand Team
Related articles