Playing radio

Starting from Nokia Asha software platform 1.0 devices, the TunerControl interface enables the development of applications that make use of the device’s radio tuner module.

The following code snippet demonstrates how you can initialize a Player instance by using the seek method call within a Thread.

public void run() {        
        try {
                Player player = Manager.createPlayer("capture://radio");
                
                player.realize();
                
                TunerControl tuner = (TunerControl) player.getControl("javax.microedition.amms.control.tuner.TunerControl");
                
                int freq = tuner.seek(975000, TunerControl.MODULATION_FM, true);
                if (freq == 0) {
                    //tuner not supported
                }
                player.start();
        } 
  catch (IOException e) {
            //catch an IOException here
        } 
  catch (MediaException e) {
            //catch a MediaException here
        }
}

Please note that the frequency value is given as 1/100th of the frequency in Hertz. In the above example the tuner will seek and play the first available radio station in the area starting from 97.5 MHz and going up to 108 MHz. Also note that radio playback requires that the headphones are plugged to the device, since they are used as an antenna.