Someone requested me to write a tutorial about making a mp3 player in vb.net by the way i actually don't have time to do it but i am here to do a simple one because i don't want to deny his request or late .. first of all right click on your toolbox and select Choose Items and a window will come up move to COM tab page in that window and search for Windows Media Player when you found it tick it and click ok button .
Double click button 2 and add these codes
Double click button 3 and add these codes
Double click button 4 and add these codes
Now debug , click add button to add mp3 files to and you know what to do next have fun i am sorry that i couldn't make it advanced i have no time from yesterday .
here is the full source code
Then you will see any tool in your toolbox that should be this (Windows Media Player)
Now drag and drop that tool in and go for it's properties and change visible property to false now go ahead and add a listbox , four buttons and a openfiledialog(enable multi select) also make your form look like this .
Change the text property of all buttons as given below
button1 - Play
button2 - Pause
button3 - Stop
button4 - Add
Now double click on button1 and add these codes
AxWindowsMediaPlayer1.URL = listbox1.SelectedItem
Double click button 2 and add these codes
AxWindowsMediaPlayer1.Ctlcontrols.pause()
Double click button 3 and add these codes
AxWindowsMediaPlayer1.Ctlcontrols.stop()
Double click button 4 and add these codes
openfiledialog1.ShowDialog() If Windows.Forms.DialogResult.OK Then For Each track As String In openfiledialog1.FileNames listbox1.Items.Add(track) Next End If
Now debug , click add button to add mp3 files to and you know what to do next have fun i am sorry that i couldn't make it advanced i have no time from yesterday .
here is the full source code
Public Class Form1 Private Sub button1_Click(sender As Object, e As EventArgs) Handles button1.Click AxWindowsMediaPlayer1.URL = listbox1.SelectedItem End Sub Private Sub button2_Click(sender As Object, e As EventArgs) Handles button2.Click AxWindowsMediaPlayer1.Ctlcontrols.pause() End Sub Private Sub button3_Click(sender As Object, e As EventArgs) Handles button3.Click AxWindowsMediaPlayer1.Ctlcontrols.stop() End Sub Private Sub button4_Click(sender As Object, e As EventArgs) Handles button4.Click openfiledialog1.ShowDialog() If Windows.Forms.DialogResult.OK Then For Each track As String In openfiledialog1.FileNames listbox1.Items.Add(track) Next End If End Sub End Class
25 comments
can you post the skin used for the form?
Replyit's not my form theme , it's my windows theme :)
Reply-Shim
I'm getting a message that the "extension (.)" of the file is not recognized. The file is the one added to the list. Same message with other files as well.
ReplyWhat kind of files did you add?
Replymp3 files
ReplyDid you check those mp3 files on your default Windows Media Player?
ReplyYes, the files do play on Media Player.
ReplyAnd also the same message appears when no files of selected and the Play button is clicked.
ReplyOkay, download this rar and it has the source code for this program https://www.dropbox.com/s/zzxylwj6m0o5wbn/mp3%20src.rar and see whether it works.
ReplyAfter comparing your code and the code I had worked on, they are exactly the same.
Replyjust to be sure, create a project from scratch, only copying and using your code instead. Compiled, same result, same message.
I am running Windows 7 64 bits and using Visual Studio 2010. Wonder if that makes a difference. What was the environment you compiled this under?
I am running Windows 7 x86(32 bits) and using Visual Studio 2012 by the way maybe there can be any problem in your media player library or the designer of media player.
Replycan you show me a screenshot of the error?
Yes,but how can I show it? The comments section does not allow that.
ReplyTake a screenshot of the error and upload it to tinypic or some other image hosting website and put the link here to the image.
ReplySorry, I've been rather busy, but here is the screenshot of the error.
Reply[url=http://postimg.org/image/6m5uoqb8j/][img]http://s21.postimg.org/6m5uoqb8j/Screen_Shot004.jpg[/img][/url]
if that does not work try this:
Replyhttp://postimg.org/image/6m5uoqb8j/
How can I know the full information about the selected song?
ReplyI mean All tags: (Artist, is copyright?, singer, file size, extension, etc...)?
And also I i can change the tags ?
Hi,
ReplyI'm planning on writing a tutorial for that..!
untill I know we can:
ReplyAxwindowmediaplayer as player.
Code.
SongNameLabel.text = player.currentmedia.getfileinfo("Title")
IsCopyrightLabel.text = player.currentmedia.getfileinfo("Copyright")
ArtistNameLabel.text = player.currentmedia.getfileinfo("artist")
durationlabel.text == player.currentmedia.duration.trim()
But how to know how much duration is passed or played?
How to get the image of that MP3 File in picturebox.?
Can we create our own visualation?
I watch one tutorial on codeproject. he used: System.drawlines() or something like this. '( Which draw random lines., But I want to import Bars to my own picturebox.)
I don't want to use the WindowMediaplayer Window
It's a strange error, I never experienced anything like this. It's better if you ask the experts on forums like Stackoverflow.
ReplyTo get the duration use this
ReplyLabel1.Text = AxWindowsMediaPlayer1.currentMedia.duration - AxWindowsMediaPlayer1.Ctlcontrols.currentPosition
Hi could you pls help me because I like to diplay the album art of my mp3 when it plays. So i try to put a picture box but i don't know the code how to extract it
ReplyTry this http://glassocean.net/perrys-id3-tag-library/
ReplyCan I ask if you could detect the music's bass in vb.net?
ReplyHi, would you please be able to tell me the code to make the songs play automatically down the list without clicking on the next song?
Replyi need a simple music player for my project, canu please help me guys, i need coding for that plz help me out
ReplyPost a Comment
Note: Only a member of this blog may post a comment.