In this article, we will be discussing about the 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.