Programming guides for beginner...
Any comments are welcomed....
I hope it helps!!! Thanks for drop by...

Saturday, January 29, 2011

My first step-by-step tutorial on Simple Music Player (VS2008) Part I

     After I posted more than 10 tutorials, I found out that it might not be useful to those beginner. So this is my first step-by-step tutorial. I hope that it will be useful to everyone. This tutorial might not be completed in only one post but at least two posts. For now, I haven’t decide about the exact number of posts I going to use.

    Tutorial start here:

    Requirements : 1) Visual Studio 2008 (VS2008) or Visual Basic 2008 Express Edition (VB2008).

                               2) Newest Direct X recommended.  Download from here.

    First, start either VS2008 or VB2008. A start page will appear. Click on create project from start page or go to File | New Project. For VS2008, choose Visual Basic | Windows | Windows Form Application while for VB2008, just simply choose Windows Form Application. Choose a name for your application and click OK. In this tutorial, I will be using Simple Music Player.

(Remarks: I am using VS2008)


Picture for New Project Dialog



After click on OK button, this should be the screen that appear

    After that, drag a button from toolbox to the form. If you can’t find toolbox, go to View | Toolbox. Toolbox will appear on the left. Follow the following picture and place four buttons to the same position. To change the button text to the same in the picture, go to the properties. Properties should be on the right but if it is not, go to View | Properties. To change button text, click on the button and look for text in the properties (The red square area on the right). Change the four buttons text to “Play”, “Stop”, “Previous”, “Next”. (ps: sorry for the wrong arrangement in the picture.)



Button1 - text:Play    - anchor:bottom,left
Button2 - text:Stop    - anchor:bottom,left
Button3 - text:Next    - anchor:bottom,left
Button4 - text:Previous    - anchor:bottom,left

Anchor is use to lock the position and size of any object that being drag into the form.

(Tip: In order to get the same size of button, drag only one button to the form. Copy the button and paste it to the form for the rest buttons.)

     Add two listviews to the form from the toolbox. Listview1 is use to show the music name while listview2 is use to store the music file path. Listview2 will be invisible by setting the properties of visible to false. Resize listview1 to any size that you like.



listview1 - allowdrop:true         - anchor:top,bottom,left,right      - view:list      - multiselect:false
listview2 - visible:false

     Add a timer into the form. Timer will be appear under the form. Change the Interval to 1. Interval is the time for timer event to elapsed. This is calculated by milliseconds. In this project, timer is use to check for ending of song and also starting the next song.



      Here, you will need to have DirectX SDK in order to proceed. There are few methods to play Music with In this tutorial, I will guide using DirectX method. In order to use DirectX, you will need to add reference to the project. Go to Project | Add Reference and the following dialog will appear. Look for Microsoft.DirectX.AudioVideoPlayback and click ok.



This will be the first part of the tutorial. This part includes only interfaces but not coding. The next part will be coding. I not sure how long do I need to complete it but I will try my best to complete it asap. Please comment for any problems.

No comments:

Post a Comment