I wrote this code and I get NullPointerException when using recordcontrol.setStream I understand that recordcontrol is null but i've checked this doc and it's exactly what they did, what am I doing wrong ? btw using JAVA ME SDK 3.4 and running this on emulator
http://developer.nokia.com/Resources...rdControl.html
Code:
package audiosurf;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.microedition.media.Manager;
import javax.microedition.media.MediaException;
import javax.microedition.media.Player;
import javax.microedition.media.control.RecordControl;

/**
 *
 * @author Roy
 */
public class AudioAnalyzer implements Runnable{
    
    private Player audioPlayer;
    private RecordControl recordControl;
    private InputStream inputStream;
    private ByteArrayOutputStream recordOutput;
    private byte recordData [];
    private Thread thread;
    private boolean recordFinished;
    
    /**
     * Constructor.
     */
    public AudioAnalyzer()
    {
        try {
            thread = new Thread(this);
            recordFinished = false;
            //inputStream = getClass().getResourceAsStream("res/getlucky.mpg");
            //audioPlayer = Manager.createPlayer(inputStream, "audio/mpg");
            audioPlayer = Manager.createPlayer("http://puu.sh/35YTG.mp3");
            //audioPlayer = Manager.createPlayer("http://puu.sh/6n9jC.mp3");
            audioPlayer.realize();
            recordControl = (RecordControl)audioPlayer.getControl("RecordControl");
            if(recordControl == null){
                System.out.println("not supported");
            }
            recordOutput = new ByteArrayOutputStream();
            recordControl.setRecordStream(recordOutput);
            recordControl.startRecord();
            audioPlayer.start();
            //thread.start();
        } catch (MediaException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
    
    /**
     * 
     * @return the recordData; 
     */
    public byte [] getRecordData()
    {
        return recordData;
    }
    
    /**
     * 
     * @return the recordFinished; 
     */
    public boolean getRecordFinished()
    {
        return recordFinished;
    }

    /**
     * Checking when the player has finished playing the audio and copy the audio's recorded data into recordData.
     */
    public void run()
    {
        try {
            Thread.sleep(audioPlayer.getDuration() / 1000);
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        }
        try {
            recordControl.commit();
            recordData = recordOutput.toByteArray();
            recordOutput.close();
            audioPlayer.close();
            recordFinished = true;
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
    
}