コード例 #1
0
  public void run() {
    try {
      player = Manager.createPlayer("capture://audio?encoding=audio/basic");
      player.realize();

      rCtl = (RecordControl) player.getControl("RecordControl");

      Control[] c = player.getControls();
      for (int i = c.length - 1; i >= 0; i--) {
        if (c[i] instanceof AudioPathControl) {
          apc = (AudioPathControl) c[i];

          oldPath = apc.getAudioPath();
          apc.setAudioPath(AudioPathControl.AUDIO_PATH_HANDSFREE);
          path = apc.getAudioPath();

          break;
        }
      }

      rCtl.setRecordStream(strm);
      rCtl.startRecord();

      player.start();
    } catch (Exception e) {
      final String msg = e.toString();
      UiApplication.getUiApplication()
          .invokeAndWait(
              new Runnable() {
                public void run() {
                  Dialog.inform(msg);
                }
              });
    }
  }
コード例 #2
0
 public void enableSpeaker(boolean value) {
   if (mPlayer == null) return; // just ignore
   AudioPathControl lPathCtr =
       (AudioPathControl) mPlayer.getControl("net.rim.device.api.media.control.AudioPathControl");
   try {
     lPathCtr.setAudioPath(
         value ? AudioPathControl.AUDIO_PATH_HANDSFREE : AudioPathControl.AUDIO_PATH_HANDSET);
     sLogger.info(
         "Speaker is "
             + (lPathCtr.getAudioPath() == AudioPathControl.AUDIO_PATH_HANDSFREE
                 ? "enabled"
                 : "disabled"));
   } catch (Throwable e) {
     sLogger.error("Cannot " + (value ? "enable" : "disable") + " speaker", e);
   }
 }
コード例 #3
0
 public boolean isSpeakerEnabled() {
   if (mPlayer == null) return false; // just ignore
   AudioPathControl lPathCtr =
       (AudioPathControl) mPlayer.getControl("net.rim.device.api.media.control.AudioPathControl");
   return lPathCtr.getAudioPath() == AudioPathControl.AUDIO_PATH_HANDSFREE;
 }