How to set up and tune the FM radio for Windows Phone 8

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

This topic describes how to connect to the FM radio in a Windows Phone app that targets Windows Phone OS 7.1.

Warning

FM radio is supported only in apps that target Windows Phone OS 7.1. If you use the FMRadio class in apps that target Windows Phone OS 8.0 or later, a RadioDisabledException indicates that the FM radio feature is not available. On Windows Phone 8 devices with a build of 8.0.10322 or greater, the run-time exception may not occur if you use the FMRadio API. However, the FMRadio API is not supported for apps that target Windows Phone OS 8.0.

This topic contains the following sections.

FMRadio API

You can access the following properties of the FMRadio class to create an instance of the radio, turn the radio on and off, and tune the radio.

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.

Enumerations in the Radio namespace:

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.

Development Considerations

  • 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 UI thread while the app is running.

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

Note

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

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

Setting Up the FM Radio

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 FMRadio class.
FMRadio myRadio = FMRadio.Instance;
// Turn the radio on.
myRadio.PowerMode = RadioPowerMode.On;

Tuning the FM Radio

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;