Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Seeking radio station using Radio Utilities Symbian API

From Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Tested on: Nokia N96, Nokia 5800 XpressMusic
Platform(s): S60 3rd Edition ,FP2
S60 5th Edition
S60 5th Edition
S60 3rd Edition FP2
Keywords: Radio Utilities, CRadioUtility, CRadioFmTunerUtility, CRadioPlayerUtility
Created: User:Kbwiki (22 Sep 2010)
Last edited: hamishwillee (01 Aug 2012)



This article explains how to seek a radio station using the Radio Utilities API.


The Radio Utilities API can be used to tune the tuner to the speficied frequency (Hz) and start playing that radio station. It can also be used to ramp up the volume.

We can search for a station starting from the currently tuned frequency and search in the direction specified (up or down). If a radio station is found while searching, that station is played.

Note.pngNote: :Radio Utilities API is not part of the public SDK. It can be found in the SDK API Plug-in from 3rd Edition, FP2 onwards. Audio Routing API is also part of SDK API Plug-in.


Required Capabilities


Required Headers

#include <AudioOutput.h> //for audio routing control
#include <radioutility.h> 
#include <radiofmtunerutility.h>
#include <radioplayerutility.h>

Engine to handle radio-related issues

The required classes are:

  CRadioUtility (The Radio Utility)
  CRadioFmTunerUtility (The Tuner Utility)
  CRadioPlayerUtility (The Player Utility)

Construction of Main Objects

void CMyRadioEngine::ConstructL()
    // create an instance of Radio Utility factory and indicate
    // FM Radio is a primary client
    iRadioUtility = CRadioUtility::NewL( ETrue );
    // Get a tuner utility
    iFmTunerUtility = &iRadioUtility->RadioFmTunerUtilityL( *this );
    // Get a player utility
    iPlayerUtility = &iRadioUtility->RadioPlayerUtilityL( *this );
    iPlayerUtility->GetMaxVolume( iMaxVolume );
    iAudioOutput = CAudioOutput::NewL( *iPlayerUtility );
    // Set audio output to current setting
    CAudioOutput::TAudioOutputPreference outputPreference = 
    //Change the outputPreference to CAudioOutput::EPublic to launch radio   
    // with loudspeaker.
    iAudioOutputtype = 0; 
    if (0 == iAudioOutputtype)
     outputPreference = CAudioOutput::ENoPreference;
    else if (1 == iAudioOutputtype)
     outputPreference = CAudioOutput::EPublic;
    #ifndef __WINS
    if ( iAudioOutput )
     iAudioOutput->SetAudioOutputL( outputPreference );
    // Assume headset is connected, we'll be notified later if it's not   
    // through MrftoRequestTunerControlComplete callback
    // Asynchronous request to get control of the FM tuner

Implementation of MRadioFmTunerObserver:: MrftoRequestTunerControlComplete

void CMyRadioEngine::MrftoRequestTunerControlComplete(
   TInt aError )
   case KErrNone:
      CEikonEnv::InfoWinL(_L("Starting Radio"),_L(""));
    //The time interval over which the volume should be increased from zero to
    //the current volume setting = 1 Sec
    // Asynchronous request to start playing the radio.
    // If radio plays successfully, the user will receive callback method      
    // with MrpoStateChage with ERadioPlayerPlaying and KErrNone.
     Tint freq = 98300000; //98.3 MHz freq;
    //Asynchronous request to tune the tuner to the speficied frequency(Hz). 
    // User must be ready to receive callback method MrftoTuneComplete  
    //Asynchronous request to find a radio station.
    //User must be ready to receive callback method MrftoSeekComplete.
   case KFmRadioErrAntennaNotConnected:
   	CEikonEnv::InfoWinL(_L("Headset not connected"),_L(""));
   case KErrAlreadyExists:
   case KFmRadioErrFmTransmitterActive:
   case KFmRadioErrOfflineMode:
   	CEikonEnv::InfoWinL(_L("Offline mode"),_L("Cant Start"));


Station Seek Complete Event

// Station seek complete event. This event is asynchronous and is received   
// after a call to CRadioFmTunerUtility::StationSeek.
void CMyRadioEngine::MrftoStationSeekComplete(TInt aError, TInt aFrequency)
   // If no error then radio tuned to frequency(Hz) of the radio station that 
   // was found 
       CEikonEnv::InfoWinL(_L("Error"),_L("Cant find station"));

Sample application

This page was last modified on 1 August 2012, at 04:40.
48 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.