javax.microedition.media.control.RecordControl Java Examples

The following examples show how to use javax.microedition.media.control.RecordControl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MediaRecorder.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public MediaRecorder(String path) throws IOException {
    try {
        String [] supportedContentType = Manager.getSupportedContentTypes("capture");
        boolean amrSupported = false;
        for (int i = 0; i < supportedContentType.length; i++) {
            if(supportedContentType[i].equals("audio/amr")){
                amrSupported = true;
            }
        }
        if(amrSupported){
            try {
                //some j2me devices will report they supports amr, but they are actually 
                //don't so we will try to realize the player and if fails the
                //fallback would be to create it with the default capture encoding
                recorder = Manager.createPlayer("capture://audio?encoding=audio/amr");                                
                recorder.realize();
            } catch (Exception e) {
                recorder = Manager.createPlayer("capture://audio");
                recorder.realize();
            }
        }else{
            recorder = Manager.createPlayer("capture://audio");
            recorder.realize();
        }
        rc = (RecordControl) recorder.getControl("RecordControl");
        out = FileSystemStorage.getInstance().openOutputStream(path);
        rc.setRecordStream(out);
    } catch (MediaException ex) {
        ex.printStackTrace();
    }
}
 
Example #2
Source File: MediaRecorder.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public MediaRecorder(String path, String mimeType) throws IOException {
    try {
        //recorder = Manager.createPlayer("capture://audio?encoding=audio/amr&bitrate=12200&voipMode=true");
        recorder = Manager.createPlayer("capture://audio?encoding="+mimeType);            
        recorder.realize();
        rc = (RecordControl) recorder.getControl("RecordControl");
        out = FileSystemStorage.getInstance().openOutputStream(path);
        rc.setRecordStream(out);
    } catch (MediaException ex) {
        ex.printStackTrace();
    }
}
 
Example #3
Source File: RecordPlayer.java    From J2ME-Loader with Apache License 2.0 4 votes vote down vote up
public RecordPlayer() {
	recorder = new MediaRecorder();
	state = RECORD_CLOSED;
	controls = new HashMap<>();
	controls.put(RecordControl.class.getName(), this);
}