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 component
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."
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!