![]() |
Multimedia »
Audio and Video »
Audio
Beginner
License: The Code Project Open License (CPOL)
Another Article on MP3 Players using Windows Media PlayerBy rspercy60Play your MP3s with this Audio Player |
VB 8.0, VB 9.0Vista, WinForms
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
This program was derived from the Ultimate Player Source which can be found on The Code Project. I added a lot of stuff to this MP3 player - current play time and time remaining, re-did the balance track bar (-100, 0, 100) min, value, max properties, respectively, to work correctly.
I do not have any design experience, so don't laugh…chuckles. This does work and is very powerful. Have fun using Audio PlayerWMP. I hate tooltips, so all tips can be found by mousing over the buttons. Tips are loaded in a textbox centered between the two columns of buttons, see picture below:
The Ultimate Player Source only lets you select one file at a time. I thought that opening, selecting 1, opening, selecting 1…(you get the idea) was not exactly what I was looking for, so I added multiselect to the Open File Dialog box.
Private Sub LoadFiles(ByVal mediaType As String)
Dim supportedFiles As String
Select Case mediaType
Case "Audio"
supportedFiles = audioFiles
Case Else
supportedFiles = audioFiles
End Select
With ofd
.InitialDirectory = "C:\Users\" & GetUserName() & "\Music\"
.Filter = supportedFiles
.CheckFileExists = True
.Multiselect = True
.RestoreDirectory = True
End With
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
For Each Me.fileNamePath In ofd.FileNames
fileNameShow = GetFileName(fileNamePath)
Me.lstFiles.Items.Add(fileNameShow)
Next
End If
End Sub
I had to add a GetUserName function (see in the picture above) so everyone could use this program. I got this code from the comments in the program:
Function GetUserName() As String
If TypeOf My.User.CurrentPrincipal Is _
Security.Principal.WindowsPrincipal Then
Dim parts() As String = Split(My.User.Name, "\")
Dim username As String = parts(1)
Return username
Else
Return My.User.Name
End If
End Function
Here is the code for the labels that I used in the timerDuration_Scroll Event…
lblTime.Text = axWMP.Ctlcontrols.currentPositionString
lblDuration.Text = Format_
(Int(axWMP.currentMedia.duration - axWMP.Ctlcontrols.currentPosition)
\ 60, "00") & ":" & _
Format(Int(axWMP.currentMedia.duration - _
axWMP.Ctlcontrols.currentPosition)
Mod 60, "00").ToString
I added code to display to the user on how much volume he or she is using, and did the same for the balance (see the above picture).
To all the authors of code that I used (all names are in comments throughout the program), I thank you all very much. Special thanks goes to the creator of Ultimate Player Source for his idea on Windows Media Player.
I have no degree, but I have had programming experience in college (Pascal and COBOL). I worked in construction for 30+ years and now retired. So I decided to take up VB as a hobbyist. I have learned quite a lot by downloading programs from The Code Project. I thank all the authors who have uploaded their articles. This is actually a better place to learn from.
| You must Sign In to use this message board. | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 12 Nov 2008 Editor: Deeksha Shenoy |
Copyright 2008 by rspercy60 Everything else Copyright © CodeProject, 1999-2009 Web21 | Advertise on the Code Project |