I want to record sound on my Java ME App on K770i. So I used this:
http://java.sun.com/javame/reference/apis/jsr135/javax/microedition/media/control/RecordControl.html
example of RecordControl in my code. It goes like this:
import java.util.Vector;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;
import javax.microedition.media.Manager;
import javax.microedition.media.MediaException;
import javax.microedition.midlet.MIDlet;
import java.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.media.*;
import javax.microedition.media.control.*;
import javax.microedition.midlet.*;
import javax.microedition.rms.*;
(...)
try {
// Create a Player that captures live audio.
Player p = Manager.createPlayer("capture://audio");
p.realize();
// Get the RecordControl, set the record stream,
// start the Player and record for 5 seconds.
RecordControl rc = (RecordControl)p.getControl("RecordControl");
ByteArrayOutputStream output = new ByteArrayOutputStream();
rc.setRecordStream(output);
rc.startRecord();
p.start();
Thread.currentThread().sleep(5000);
rc.commit();
p.close();
} catch (IOException ioe) {
} catch (MediaException me) {
} catch (InterruptedException ie) { }
But unfortunately when I try to build it, it tells me:
*** Creating directories ***
*** Compiling source files ***
..\src\example\audiodemo\AudioPlayer.java:121: cannot find symbol
symbol : class RecordControl
location: class example.audiodemo.AudioPlayer
RecordControl rc = (RecordControl)p.getControl("RecordControl");
^
..\src\example\audiodemo\AudioPlayer.java:121: cannot find symbol
symbol : class RecordControl
location: class example.audiodemo.AudioPlayer
RecordControl rc = (RecordControl)p.getControl("RecordControl");
^
2 errors
So my question is: why there is no RecordControl class if in documentations it is written this class should be there. Or is there other method to record / capture audio from microfone in Java ME of Sony Ericsson?
How do you record sound?