Create a Visual Basic Radio Player

| May 7, 2012 | 1 Comment

visual basic radio player

Learn how to create your own custom radio player with the free download version of Visual Basic 2010.

There are lots of fun applications that you can create with Microsoft Visual Basic 2010 utilizing the features that are built into Windows. Here I’ll show you how to create a radio player that plays your favourite stations.

This project uses the free Visual Basic Express Edition 2010 which you can download from: http://msdn.microsoft.com/en-us/vbasic/default.

To begin, launch the program and create a new project by choosing File > New Project. Choose Windows Form Application, type the name MyRadioPlayer and click Ok.

The radio player will make use of the Windows Media Player interface which comes with Windows. However, this tool is not available from the toolbox so you’ll need to add it manually. To do this, open the Toolbox panel, right click any position in the toolbox and choose Choose Items. This opens a Choose Toolbox Items dialog. The tool you need is a COM component so click the COM Components tab and scroll down to find the Windows Media Player tool. Select its checkbox and click Ok.

visual basic radio player step 1

Now the Windows Media Player will be added to the toolbox and you can drag and drop it onto the form. When it appears, it will a small size object so resize it to fill most of the form.

Click an empty place on the form and from the Properties dialog, set the Form1 Text property to read My Radio Player.

visual basic radio player step 2

Add at least two more buttons to the form – each button will run one radio station – and you will want an extra button to click to exit the program.

Set the Text property of each button either to the station name or type Quit. Double click the Quit button and type this between the Sub and End Sub statements:

End

Double click on another button and, for example, to set it to play Triple J type this code between the Sub and End Sub statements:

AxWindowsMediaPlayer1.URL = "http://abc.net.au/res/streaming/audio/windows/triple_j.asx"

step 3

This code will play the BBC1 radio stream:

AxWindowsMediaPlayer1.URL = "http://www.bbc.co.uk/radio/listen/live/r1.asx"

Once you have a couple of stations added you can test the application by selecting Start Debugging or press F5. Click a button to connect to a live stream and, once it has buffered, it will start playing in the player. Use the controls that come with the Windows Media Player object to pause or restart the streaming.

step 4

You can customize the Windows Media Player control by right clicking it and choose Properties. There are various properties that you can set including those that configure the controls, layout, playback options and volume for the player.

You can now add more buttons for all your favourite stations and, if desired, test your VB skills by adding a text box and an additional button so you can paste a station’s URL into the text box and play it by clicking the button.

How to find stations to play

The web is a good source of radio stations to play on your player. For example, at this website http://www.abc.net.au/radio/listenlive.htm#upgrades you will find links to the Windows Media Player audio streams for all major ABC stations.

finding stations step 1

When you are searching for the URLs to use look for URLs that point to .asx files – these are files that the player can play. A search such as BBC radio direct link asx , for example, will help you locate direct links for BBC radio streams.

finding stations to play step 2

For each radio stream, add a button to the form, set the button’s Text property to the name of the station and then add the code that links to that stream so it will play in the player. The only change from one button to the next is the URL of the stream.

finding stations to play step 3

 

Tags: , , , , , , , ,

Category: Visual Basic

About the Author ()

Comments (1)

Trackback URL | Comments RSS Feed

  1. jamal ismail salah says:

    woooooooooow thanks boss

Leave a Reply