FM Radio Programming In Windows Phone 7

Mahakgarg
Posted by in Windows Phone category on for Beginner level | Points: 250 | Views : 6748 red flag
Rating: 5 out of 5  
 1 vote(s)

In this article, we will be discussing about the FM Radio programming in windows phone 7.


 Download source code for FM Radio Programming In Windows Phone 7

Objective

The Objective of this article to describe some features of the FM Radio in Windows Phone 7


Using the code

In this article, we will be discussing about the FM Radio programming in windows phone 7.  For this Follow these steps:

Step1: 

First we add a namespace Microsoft.Devices.Radio (as it contains the FMRadio API).

using Microsoft.Devices.Radio;

using Microsoft.Devices.Radio;

Step2:

After that we write the following code after the InitializeComponent();

public MainPage()

{

InitializeComponent();

 

try

{

FMRadio.Instance.CurrentRegion = RadioRegion.UnitedStates;

FMRadio.Instance.PowerMode = RadioPowerMode.On;

FMRadio.Instance.Frequency =101.5 ;

if (FMRadio.Instance.SignalStrength == 0.0)

{

MessageBox.Show("Please connect your phone to the headset.");

}

}

catch (Exception ex)

{

MessageBox.Show("Error Message:-> " + ex.Message + "FM Radio is not connected");

}

}

Step3: (We will discuss the program)

In the first line, we specify the current region of the FM Radio like this:

FMRadio.Instance.CurrentRegion = RadioRegion.UnitedStates;

here we set two other countries name (Europe, Japan). Only these names are provided by .net.

In the Second line, we set the PowerMode of the FM Radio to On. we can  also set it to Off.

FMRadio.Instance.PowerMode = RadioPowerMode.On;

In the Third Line, we set the Frequency of the program. We can tune it into this frequency.

FMRadio.Instance.Frequency =101.5 ;

Here we specify 101.5

In the Forth Line, we sets the value of the SignalStrength, which is based on RSSI( Received Signal Strength Indicator). Here we check if the Signal Strength will be 0.0, the MessageBox will be appear.

if (FMRadio.Instance.SignalStrength == 0.0)

{

MessageBox.Show("Please connect your phone to the headset.");

}

                 

and if there was an error the following message will be appear:           

catch (Exception ex)

{

MessageBox.Show("Error Message:-> " + ex.Message + "FM Radio is not connected");

}

Conclusion


Here we discuss about that how we can listen the FM radio In Windows Phone 7.

Hope you liked it, do let me know any comments or feedback.
Page copy protected against web site content infringement by Copyscape

About the Author

Mahakgarg
Full Name: Mahak Garg
Member Level: Starter
Member Status: Member
Member Since: 8/27/2011 2:28:41 PM
Country: India
Mahak
http://www.dotnetfunda.com

Login to vote for this post.

Comments or Responses

Posted by: Vuyiswamb on: 4/18/2013 | Points: 25
This is a very interesting and simple article.

Login to post response

Comment using Facebook(Author doesn't get notification)