2 out of 6 rated this helpful - Rate this topic

How to: Set up and Tune the FM Radio for Windows Phone

Windows Phone

March 22, 2012

This topic describes how to work with the FMRadio API. You can access the following FMRadio class properties and enumerations to perform functions such as creating an instance of the radio, turning the radio on and off, and tuning the radio.

The following table shows FMRadio properties.

Property

Description

CurrentRegion

Sets the frequency region information for the radio.

Frequency

Tunes the FM radio to a specified frequency.

Instance

Returns an instance of the FM radio.

PowerMode

Sets the RadioPowerMode of the device. Setting this property turns the device radio on or off.

SignalStrength

Retrieves the received signal strength indicator (RSSI) value for the currently-tuned frequency.

FMRadio Enumerations:

Enum

Description

RadioPowerMode

An enumeration that contains the possible power modes of the radio. The current RadioPowerMode values are On and Off.

RadioRegion

An enumeration that contains the set of radio frequency regions available for radio tuning.

The current values are Europe, Japan, and UnitedStates.

  • It can take up to three seconds for the first FMRadio method call to return after the phone boots up.

  • After the FM Radio is first initialized, if the phone is running in an active state, the methods will typically return within 100 ms.

  • Avoid setting up the FM Radio or synchronizing the Silverlight UI thread while the application is running.

  • Delay sending further commands to the FM Radio until at least one second after the FM Radio is enabled.

Note Note:

multiple devices The 7x27a processor does not allow accessing the FM radio and microphone simultaneously.

For more information and performance tips, see Creating High Performance Silverlight Applications for Windows Phone.

To set up the FM radio:

Add a using directive to include the Microsoft.Devices.Radio namespace, which contains the FMRadio API.

using Microsoft.Devices.Radio;

Create an instance of the FMRadio class and then set the power mode.

// Create an instance of the radio.
FMRadio myRadio = FMRadio.Instance;

// Turn the radio on.
myRadio.PowerMode = RadioPowerMode.On;

To tune the FM radio:

Set the radio region and the frequency. You need to set the radio region only once for the duration of the application’s execution.

Note

The FM Tuner may take up to one second to complete the tuning operation. Delay sending further commands to the FM Radio until at least one second after the FM Radio is enabled.

// Set the region. 
myRadio.CurrentRegion = RadioRegion.UnitedStates;

// Set the frequency.
myRadio.Frequency = 94.9;

Did you find this helpful?
(1500 characters remaining)