Library tutorials & articles

Build an MP3 Player

Building the Form

To begin, create a standard Visual Basic project. Next, select Projects | Components from the menu bar, and select Windows Media Player in the resulting dialog box. Click OK to add the component to your project. Now, select it from the Toolbox and drop it onto the default form. We'll use the component's built-in user interface for all the standard features like play, pause and stop. Resize the Media Player OCX as necessary, as shown in Figure B.

Figure B: We'll use the Windows Media Player for built-in features such as playing, pausing and stopping MP3 playback.

Adding controls

As we mentioned, in addition to playing MP3 files, we want the application to read and write certain information about each song--otherwise known as tag information. As an added bonus, we'll retrieve the file length and calculate the current playing time. To do so, however, we'll need to add a few more controls to our form. Use Figure A as a template for dropping in the appropriate controls. To display the MP3 tag information, add seven textboxes named as follows: txtTitle, txtArtist, txtAlbum, txtYear, txtComment and txtGenreCode. In addition, drop in a combobox called Combo1, two command buttons named cmdOpen and cmdWriteTage, a directory, drive and filelist box, a timer control and two labels named lblTotalTime and lblElapsedTime. All other controls can retain the standard VB assigned names.

Change the FileListBox's Pattern property to *.mp3 so that it displays only MP3 files. Finally, alter the label controls to read Total Time and Elapsed Time. Set the Timer control's Interval property to 60. If you want, you can add several additional labels beside the textboxes and name them as we have.

Comments

  1. 25 Aug 2009 at 02:30

    What version of VB are you running in order to rpoduce this player? I am running VB6 at the moment and cannot compile this player, any chance of rewriting the script for Vb6 for me please as i am only new to Vb and still trying to learn.

    Thanks, Jameson

Leave a comment

Sign in or Join us (it's free).

ElementK Journals
AddThis

Related podcasts

  • Christian Beauclair

    14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...

Want to stay in touch with what's going on? Follow us on twitter!