FMRadio will be back in Windows Phone 8 GDR2: Use it with care!

When we look at what’s new in the GDR2, we will be served with the FMRadio API again. The API itself wasn’t gone really, only the implementation does fire exceptions. But we know we can use the FMRadio again from GDR2. How could we write code that doesn’t fail because of this?

So we need to know the version number from which the GDR2 release starts to be able to write code that checks the version number against the GDR2 release version number.

When we look at the Windows Phone 8 update history, we actually see two version numbers for the GDR2 release. The version number depends on the specific phone model and mobile operator, it could be either 8.0.10327.77 or 8.0.10328.78. My guess is to only check against the lowest version number of the two. However the SDK emulator update for GDR2 shows a different version number 8.0.10322.0. So I better use that lower version number so you can use the emulator. So before you try to use the FMRadio in your Windows Phone 8 app, check if the API is even supported. Besides it can still happen that your phone doesn’t even support FMRadio (which is the case for the emulator (as far as I know).

Hope this code helps you when you want to write code against the FMRadio in a Windows Phone 8 app.

var gdr2Version = new Version(8,0,10322,0);
FMRadio radioInstance = null;
if (Environment.OSVersion.Version >= gdr2Version)
{
    try
    {
        radioInstance = FMRadio.Instance;
    }
    catch (RadioDisabledException)
    {
        radioInstance = null;
    }
}
if (radioInstance != null)
{
    //Do the operations you want to do on the Radio Instance.
}

 

Update August 12th:

Pedro Lamas, wrote an excellent article which is related: FMRadio vs. BackgroundAudioPlayer... fight!!

Basically, even if you’re not using the FMRadio directly, you should be aware of a problem that exists in the GDR2 update which affect all apps that use audio, whether it’s using the BackgroundAudioPlayer or just simply a MediaElement. Read Pedro’s article for the details.

Gravatar