1. Tech

Your suggestion is on its way!

An email with a link to:


was emailed to:

Thanks for sharing About.com with others!

Your first MP3 Delphi player
Part 1: Delphi plays MP3? TMediaPlayer is all we need!
 More of this Feature
• Part 2: mp3Player GUI
• Part 3: mp3Player Code
• Part 4: ID3 Tag Editing
• Part 5: Project's Code
 Join the Discussion
"Post your views, or look for guidance on the questions and issues that matter to coding an mp3 player with Delphi."
Learn more
  Related Resources
• Multimedia VCL/Tools
• Records in Object Pascal
• File I/O with Delphi
• BrowseForFolder dialog
 From Other Guides
• About MP3/MIDI Music
 Elsewhere on the Web
• Playing MP3's using IMediaControl -DirectX
• MP3 Playback with free XAudio VCL

It's party time.
You probably know this: MP3 is a music format where inaudible parts of music are left out, and the rest of the data are compressed. The results are quite impressive. A 64 MB song usually becomes 3-4 MB when converted to MP3 format.

MP3 is THE trend these days, and believe it or not, it seems that one of the first tasks of multimedia developers is to build a MPEG Layer 3 player.
What are we waiting for? Let's see how to use Delphi to build a MP3 player with the TMediaPlayer component. Let us not stop here. This article will show you how to extract (and even change) some more information about the MP3. The most popular tag encryption appears to be ID3. This tag holds the MP3's title, author, genre and some other information...

Just for the records: to code a MP3 player with Delphi we have several possibilities. First: we could write a program that remotely controls another application like the WinAmp player. Second: we could use some third-party MP3 component like XAudio; and third: we could use DirectX with IMediaControl to build a player.

MP3 with TMediaPlayer?
Remember the TMediaPlayer? Yep, even though it seems that our good-old TMediaPlayer is unable to playback a MP3 file, we'll see that this is, hopefully, wrong.

TMediaPlayer componentTMediaPlayer icon
VCL provides the TMediaPlayer component (located on the System tab of the Component palette) for all the major features of multimedia programming. If you look in the Delphi Help system you'll see that the "MediaPlayer component enables your application to control a media playing or recording device such as a CD-ROM player, video player/recorder, or MIDI sequencer."

MediaPlayer on Screen

One of the properties of the MediaPlayer is DeviceType. This property holds/contains the multimedia device types that can be opened by a TMediaPlayer component. Several multimedia device types are defined, but none of them is strict MP3. By default, when we put a MediaPlayer on a form, this property is set to dtAutoSelect to have the device type automatically selected based on the filename extension. At design time, we use a file open dialog box to specify the FileName property by clicking the ellipses button (...) in the Object Inspector. If we try to specify a MP3 file at design time we'll see that there is no *.MP3 selection; only AVI, MIDI, or WAVE. This will probably lead you to conclusion that TMediaPlayer is unable to reproduce a MP3 file - wrong!

Next page > Building a MP3 player Delphi Project's GUI > Page 1, 2, 3, 4, 5

©2016 About.com. All rights reserved.