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.
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.
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.
Sets the frequency region information for the radio.
Tunes the FM radio to a specified frequency.
Returns an instance of the FM radio.
Sets the RadioPowerMode of the device. Setting this property turns the device radio on or off.
Retrieves the received signal strength indicator (RSSI) value for the currently-tuned frequency.
Enumerations in the Radio namespace:
An enumeration that contains the possible power modes of the radio. The current RadioPowerMode values are On and Off.
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 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.
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.
To set up the FM radio:
Add a using directive to include the Microsoft.Devices.Radio namespace, which contains the FMRadio API.
Create an instance of the FMRadio class and then set the power mode.
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.
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.