bloddyapache (12-20-2009),Critted (10-24-2010),docoon (12-11-2009),iWAFFLE (12-06-2009),Katie_Perry (12-11-2009),kellisis (08-05-2013),MicroManage (12-19-2009),mnpeep (12-16-2009),Nitehawk772 Bkup (10-13-2011),nxkun (11-29-2011)
Yes!
No!
No, It did not work!
Yes, Make more!
None of the above.
Hello everyone, Jerry here. Today I am going to show you how to make your own media player.
The media player can do the following things:
~Play Music
~Play Videos
~Play media
~Rewind
~Play
~Pause
~(All media options)...
I used Visual Basic 2008 express edition.
Make sure that you name everything the same as I name, or it won't work!
What you need:
~A form
~Main Menu
~opd
~Windows media player preset
Don't worry, I will explain how to get all of those later on.
1.) Start of by giving your form the following properties:
Text = Media Player
Show Icon = False
Maximize box = False
Form Border Style = FixedSingle
Auto scale mode = Font
Size = 822; 587
2.) Once you've done that, we need to add our player. You can to that by doing the following:
1. Right click on any tool in your toolbox.
2. Click on 'Choose Items' (May take a while to load...)
3. Click on the 'COM Components' tab.
4. Search for 'Windows Media Player', and check the checkbox.
5. Hit Ok.
3.) Now go to your Toolbox and drag the new tool we added (Windows Media Player) into your form.
4.) Give it the following properties:
Name = player
Size = 815; 539
5.)Ok! We have finished adding our player. Now we need to add a Main Menu. You can do that by:
Go to your toolbox and search for something called 'MainMenu'. If you don't have it, than do the same thing to add it as we did with the Media Player.
In the first row you add and name:
-File (Name = 'file')
-Player (Name = 'MenuItem1')
-Volume (Name = 'MenuItem2')
Now it should pretty much look like this:
[IMG]https://i655.photobucke*****m/albums/uu276/j3r0x_2009/tut1.jpg[/IMG]
1. In the File row you add and name:
-Open (Name = Open)
-Exit (Name = mexit)
2. In the Player row you add and name:
-Play (Name = play)
-Stop (Name = mstop)
-Pause (Name = mpause)
3. And at last, in the Volume row you add and name:
-Up (Name = mup)
-Down (Name = mdown)
-Mute (Name = mmute)
So it should look like this:
[IMG]https://i655.photobucke*****m/albums/uu276/j3r0x_2009/tut2.jpg[/IMG]
6.) Now we need one more thing before we start on the coding. This thing will open your media up.
1. Go to your tool box and search for 'Open File Dialog.'
2. Drag it into your Form, and you are finished.
7.) Hehe! We are finished with that. But our Media Player does not do anything yet!! Here comes the Coding :
Open function code:
This code will browse for your selection.Try
opd.InitialDirectory = "c:\"
opd.ShowDialog()
player.URL = opd.FileName
player.Ctlcontrols.play()
Catch ex As Exception
MessageBox.Show("An error has occured, please try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Exit Function code:
This code will close the program.Application.Exit()
Play Function Code:
This code will play the player.player.Ctlcontrols.play()
Stop Function Code:
This Code will stop the player.player.Ctlcontrols.stop()
Pause Function Code:
This code will pause the player.player.Ctlcontrols.pause()
Up Function Code:
This code will turn the volume up.player.settings.volume = player.settings.volume + 10
Down Function Code:
This code will turn the volume down.player.settings.volume = player.settings.volume - 10
Mute Function Code:
This code will mute the player.If player.settings.volume = player.settings.mute() Then
player.settings.volume = 20
Else
player.settings.volume = player.settings.mute()
End If
Entire Code:
Test your player, and enjoy!!Public Class Form1
Private Sub Open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Open.Click
Try
opd.InitialDirectory = "c:\"
opd.ShowDialog()
player.URL = opd.FileName
player.Ctlcontrols.play()
Catch ex As Exception
MessageBox.Show("An error has occured, please try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub mexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mexit.Click
Application.Exit()
End Sub
Private Sub play_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles play.Click
player.Ctlcontrols.play()
End Sub
Private Sub mstop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mstop.Click
player.Ctlcontrols.stop()
End Sub
Private Sub mpause_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mpause.Click
player.Ctlcontrols.pause()
End Sub
Private Sub mup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mup.Click
player.settings.volume = player.settings.volume + 10
End Sub
Private Sub mdown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mdown.Click
player.settings.volume = player.settings.volume - 10
End Sub
Private Sub mmute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mmute.Click
If player.settings.volume = player.settings.mute() Then
player.settings.volume = 20
Else
player.settings.volume = player.settings.mute()
End If
End Sub
End Class
It does not hurt to click thanks!
Enjoy the player,
~Jerry
bloddyapache (12-20-2009),Critted (10-24-2010),docoon (12-11-2009),iWAFFLE (12-06-2009),Katie_Perry (12-11-2009),kellisis (08-05-2013),MicroManage (12-19-2009),mnpeep (12-16-2009),Nitehawk772 Bkup (10-13-2011),nxkun (11-29-2011)
nice but i have already learnd this
everybody lies
docoon (12-11-2009)
docoon (12-11-2009)
Why don't you make one without the windows media preset? I would make a tut but I'm too lazy :P
im at the coding part where do i paste the funt im very new to vb
Thanks,but it's just a tad bit confusing =C
the book i posted on vb tells you how to do this ^^.
but nice tut!
Jerry12358 (12-07-2009)
didn't learned the video player.
Good TUT
Thanks newb here :]