1 Reply Latest reply: Jun 1, 2010 7:46 AM by Darryl Burke RSS

    WTK SDK 3.0 for OSX problem with capturing audio, emulator

    843851
      Hello all,
      i'm installed the WTK SDK 3.0 for osx and everything works well. Some test applications also work.

      Now I'm trying to realize my project and get strange error.
      I want to capture some audio form the microphone. But when i do so the Emulator strikes with this error:

      javax.microedition.media.MediaException: Player cannot be created for capture://audio

      so i tried this: System.getProperty("supports.recording") and it returns false. But when i read over the specification of the WTK it says that it should support the Audio capturing. Is this error based on the implementation of the WTK on OSX or have some Windows users also the same problem?

      here is my implementation for the Audio recording:
       public void commandAction(Command comm, Displayable disp){
              if(comm==recordCommand){
                  try{
                      p = Manager.createPlayer("capture://audio");
                      p.realize();
                      RecordControl rc = (RecordControl)p.getControl("RecordControl");
                      ByteArrayOutputStream output = new ByteArrayOutputStream();
                      rc.setRecordStream(output);
                      rc.startRecord();
                      p.start();
                      messageItem.setText("recording...");
                      Thread.currentThread().sleep(5000);
                      messageItem.setText("done!");
                      rc.commit();
                      recordedSoundArray = output.toByteArray();
                      p.close();
                  } catch (IOException ioe) {
                      errorItem.setLabel("Error");
                      errorItem.setText(ioe.toString());
                  } catch (MediaException me) {
                      errorItem.setLabel("Error");
                      errorItem.setText(me.toString());
                  } catch (InterruptedException ie) {
                      errorItem.setLabel("Error");
                      errorItem.setText(ie.toString());
                  }
              } else if(comm == playCommand) {
                  try {
                      ByteArrayInputStream recordedInputStream = new ByteArrayInputStream
                            (recordedSoundArray);
                      Player p2 = Manager.createPlayer(recordedInputStream,"audio/basic");
                      p2.prefetch();
                      p2.start();
                  }  catch (IOException ioe) {
                      errorItem.setLabel("Error");
                      errorItem.setText(ioe.toString());
                  } catch (MediaException me) {
                      errorItem.setLabel("Error");
                      errorItem.setText(me.toString());
                  }
              }
          }
          
      any help would be grateful!

      thx and greetings

      Edited by: nYmou on Jun 1, 2010 3:44 AM