VB 2008 Tutorial - Featured Media Player
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
Hi, Now i`m gonna show you how to make your own too advanced and featured Media Player in VB.NET
Insert 1 Media Player, 13 Buttons, 1 ScrollBar, 1 Timer, 1 ListBox, 2 Checkbox, 2 TrackBar, 6 label and a OpenFileDialog :P
In properties rename all the buttons text into following below
Button1 into Play
Button2 into Pause
Button3 into Undo Pause
Button4 into Stop
Button5 into Next
Button6 into Previous
Button7 into Full Screen
Button8 into Import Media Files into Media PlayList
Button9 into Clear Media PlayList
Button10 into Play All Files
Button11 into Save Playist
Button12 into Load PlayList
Button13 into Shuffle
Now in Properties rename text of the Labels as following below
Name a Label1 text into Media Player Screen
Name a Label2 text into Media PlayList
Name a Label3 text into Audio Volume
Name a Label4 text into Audio balance
Name a Label5 text into 00:00
Name a Label6 text into ...
Place all the Labels as you wish! ;)
Design your Media Player looks as you wish, Then now start coding! ;)
Double click and insert this code into Button1
Double click ScrollBar1 and insert this code into it
Double click Timer1 and insert this code into it
Double click and insert this code into CheckBox1
Double click CheckBox2 and insert this code into it
Make a TrackBar1 Minimum into 0
Make a TrackBar1 value into 100
Make a TrackBar2 Maximum into 100
Make a TrackBar2 Minimum into 0
Make a TrackBar2 value into 100
Double click and insert this code into TrackBar1
*******************Thanks for reading my tutorial, I think this Tutorial will be most helpful to you!*******************
If you want any custom tutorial for you or you need any help in VS.NET, VB.NET, Software Coding, Designing and much more any help in Computer stuffs just ask me
Mostly i will help everyone in coding and design stuffs in on Computer
- Best regards hehaho;
- Tvs Praveen wahooo;
- Thanks CodeNStuff! for this amazing Website cooll;
Insert 1 Media Player, 13 Buttons, 1 ScrollBar, 1 Timer, 1 ListBox, 2 Checkbox, 2 TrackBar, 6 label and a OpenFileDialog :P
In properties rename all the buttons text into following below
Button1 into Play
Button2 into Pause
Button3 into Undo Pause
Button4 into Stop
Button5 into Next
Button6 into Previous
Button7 into Full Screen
Button8 into Import Media Files into Media PlayList
Button9 into Clear Media PlayList
Button10 into Play All Files
Button11 into Save Playist
Button12 into Load PlayList
Button13 into Shuffle
Now in Properties rename text of the Labels as following below
Name a Label1 text into Media Player Screen
Name a Label2 text into Media PlayList
Name a Label3 text into Audio Volume
Name a Label4 text into Audio balance
Name a Label5 text into 00:00
Name a Label6 text into ...
Place all the Labels as you wish! ;)
Design your Media Player looks as you wish, Then now start coding! ;)
Double click and insert this code into Button1
Code: Select all
Double click and insert this code into Button2AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem
Code: Select all
Double click and insert this code into Button3AxWindowsMediaPlayer1.Ctlcontrols.pause()
Code: Select all
Double click and insert this code into Button4AxWindowsMediaPlayer1.Ctlcontrols.play()
Code: Select all
Double click and insert this code into Button5AxWindowsMediaPlayer1.Ctlcontrols.stop()
Code: Select all
Double click and insert this code into Button6Dim TrackRandom As Integer
TrackRandom = Int((ListBox1.Items.Count))
AxWindowsMediaPlayer1.Ctlcontrols.next()
Code: Select all
Double click and insert this code into Button7Dim TrackRandom As Integer
TrackRandom = Int((ListBox1.Items.Count))
AxWindowsMediaPlayer1.Ctlcontrols.previous()
Code: Select all
Double click and insert this code into Button8AxWindowsMediaPlayer1.fullScreen = True
Code: Select all
Double click and insert this code into Button9OpenFileDialog1.ShowDialog()
Code: Select all
Double click and insert this code into Button10ListBox1.Items.Clear()
Code: Select all
Double click and insert this code into Button11Dim TrackURL
Dim Playlist As WMPLib.IWMPPlaylist = AxWindowsMediaPlayer1.newPlaylist("MyPlayList", "")
For Each TrackURL In ListBox1.Items
Playlist.appendItem(AxWindowsMediaPlayer1.newMedia(TrackURL))
Next
AxWindowsMediaPlayer1.currentPlaylist = Playlist
AxWindowsMediaPlayer1.Ctlcontrols.play()
Code: Select all
Double click and insert this code into Button12Dim FileWriter As StreamWriter
Dim results As DialogResult
results = SaveFileDialog1.ShowDialog
If results = DialogResult.OK Then
FileWriter = New StreamWriter(SaveFileDialog1.FileName, False)
End If
Code: Select all
Double click and insert this code into Button13Dim oresults As DialogResult
oresults = OpenFileDialog2.ShowDialog()
If oresults = Windows.Forms.DialogResult.OK Then
Dim ioFile As New StreamReader(OpenFileDialog2.FileName)
Dim ioLine As String
Dim ioLines As String
ioLine = ioFile.ReadLine
ListBox1.Items.Add(ioLine)
ioLines = ioLine
While Not ioLine = ""
ioLine = ioFile.ReadLine
ioLines = ioLines & vbCrLf & ioLine
If ioLine <> "" Then
ListBox1.Items.Add(ioLine)
End If
End While
ioFile.Close()
End If
Code: Select all
In Properties of ScrollBar1 make TabIndex into 6Dim TrackRandom As Integer
TrackRandom = Int((ListBox1.Items.Count) * Rnd())
AxWindowsMediaPlayer1.URL = (ListBox1.Items(TrackRandom))
Double click ScrollBar1 and insert this code into it
Code: Select all
In Properties of Timer1 make Enabled into True and make Interval into 1124Try
If (AxWindowsMediaPlayer1.currentMedia.duration <> 0) Then
Dim NewPerc As Double = Convert.ToDouble(ScrollBar1.Value) / 100
Dim DurationVar As Integer = Convert.ToInt32(AxWindowsMediaPlayer1.currentMedia.duration * 1000)
Dim NewPos As Integer = (DurationVar * NewPerc) / 1000
AxWindowsMediaPlayer1.Ctlcontrols.currentPosition = NewPos
Else
ScrollBar1.Value = 0
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
Double click Timer1 and insert this code into it
Code: Select all
Rename a text of CheckBox1 into Mute AudioIf AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPlaying Then
Select Case track
Case "0"
Label6.Text = "Title: " & AxWindowsMediaPlayer1.currentMedia.getItemInfo("title")
track += 1
Case "1"
Label6.Text = "Artist: " & AxWindowsMediaPlayer1.currentMedia.getItemInfo("artist")
track += 1
Case "2"
Label6.Text = "Genre: " & AxWindowsMediaPlayer1.currentMedia.getItemInfo("genre")
track += 1
Case "3"
Label6.Text = "Media Name: " & AxWindowsMediaPlayer1.currentMedia.name
track += 1
Case "4"
Label6.Text = "Duration: " & AxWindowsMediaPlayer1.Ctlcontrols.currentPositionString
track += 1
Case "5"
Label6.Text = "File Path: " & AxWindowsMediaPlayer1.currentMedia.sourceURL
track += 1
Case "6"
Label6.Text = "Media Code: " & AxWindowsMediaPlayer1.Ctlcontrols.currentPosition
track += 1
Case "7"
Label6.Text = "Time: " & TimeOfDay
track += 1
Case "8"
Label6.Text = "Date: " & DateString
track = 0
Case Else
Label6.Text = "..."
End Select
If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsStopped Then
Label6.Text = "Player Stopped..."
End If
End If
Double click and insert this code into CheckBox1
Code: Select all
In Properties of CheckBox2 make text into Enable RepeatIf CheckBox1.Checked = True Then
AxWindowsMediaPlayer1.settings.volume = 0
Else
AxWindowsMediaPlayer1.settings.volume = 100
End If
Double click CheckBox2 and insert this code into it
Code: Select all
Make a TrackBar1 Maximum into 100If CheckBox1.Checked = True Then
AxWindowsMediaPlayer1.settings.setMode("loop", True)
Else
AxWindowsMediaPlayer1.settings.setMode("loop", False)
End If
Make a TrackBar1 Minimum into 0
Make a TrackBar1 value into 100
Make a TrackBar2 Maximum into 100
Make a TrackBar2 Minimum into 0
Make a TrackBar2 value into 100
Double click and insert this code into TrackBar1
Code: Select all
Double click and insert this code into TrackBar2AxWindowsMediaPlayer1.settings.volume = TrackBar1.Value
Code: Select all
Insert this at very top above Public Class Form1AxWindowsMediaPlayer1.settings.balance = TrackBar2.Value
Code: Select all
Insert this at below Public Class Form1Imports System.IO
Code: Select all
Double click Form and insert this code into itPrivate PlayAgain As Boolean
Public track = 0
Code: Select all
Insert this text in OpenFileDialog1 Properties Filename and in TitleAxWindowsMediaPlayer1.settings.volume = TrackBar1.Value
AxWindowsMediaPlayer1.settings.balance = TrackBar2.Value
Code: Select all
Insert this in OpenFileDialog1 Properties Filter Import Media File(s) into Media PlayList
Code: Select all
Double click and insert this code into OpenFileDialog1All Type Of Media Files|*.*|MPG2 Media Files [MPG]|*.mpg|Windows Media Video [WMV]|*.wmv|DIVX Media Files [DIVX]|*.divx|MOV Media Files [MOV|*.mov|Flash Video [FLV]|*.flv
Code: Select all
Double click and insert this code into ListBox1For Each track As String In OpenFileDialog1.FileNames
ListBox1.Items.Add(track)
Next
Code: Select all
Now debug, Your`s superb Advanced Featured Media Player is ready! cooll; AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem
*******************Thanks for reading my tutorial, I think this Tutorial will be most helpful to you!*******************
If you want any custom tutorial for you or you need any help in VS.NET, VB.NET, Software Coding, Designing and much more any help in Computer stuffs just ask me
Mostly i will help everyone in coding and design stuffs in on Computer
- Best regards hehaho;
- Tvs Praveen wahooo;
- Thanks CodeNStuff! for this amazing Website cooll;
Last edited by tvs praveen on Sat Jan 23, 2010 6:07 am, edited 2 times in total.
very nice man, really thanks for this
BUT..
i have a problem..
If a hit the button: load playlist, and i choose a mp3 file, get I this message:
"Exception from HRESULT: 0xC00D1325"
Can you help me please ?

i have a problem..
If a hit the button: load playlist, and i choose a mp3 file, get I this message:
"Exception from HRESULT: 0xC00D1325"
Can you help me please ?

geenID wrote:very nice man, really thanks for thisThis Media Player features will 100 % works well, Note: If you open MP3 or any other Audio file from "Load PlayList" will never work, "Load PLayList" button feature is given to only load PlayList type fromats not to load Audio files, To open any other Media files click "Import Media File" ButtonBUT..
i have a problem..
If a hit the button: load playlist, and i choose a mp3 file, get I this message:
"Exception from HRESULT: 0xC00D1325"
Can you help me please ?

Last edited by tvs praveen on Fri Jan 22, 2010 6:22 pm, edited 1 time in total.
geenID wrote:very nice man, really thanks for thisMaybe because Loading Playlist button is made for Loading playlists and not MP3 files... hehaho;BUT..
i have a problem..
If a hit the button: load playlist, and i choose a mp3 file, get I this message:
"Exception from HRESULT: 0xC00D1325"
Can you help me please ?
Nery wrote:Yes your right NerygeenID wrote:very nice man, really thanks for thisMaybe because Loading Playlist button is made for Loading playlists and not MP3 files... hehaho;BUT..
i have a problem..
If a hit the button: load playlist, and i choose a mp3 file, get I this message:
"Exception from HRESULT: 0xC00D1325"
Can you help me please ?
lewisfroom wrote:You need 13 buttons?
Yes, 13 Buttons for 13 different features! wahooo;
ok thanks, but how must i resolve this problem?
btw; SOURCE CODE for BUTTON 13 is missing
btw; SOURCE CODE for BUTTON 13 is missing

Yeah not a good tutorial since some errors come up
Copyright Information
Copyright © Codenstuff.com 2020 - 2023