日期:2014-05-20  浏览次数:20657 次

NOKIA手机上用J2ME通过音频口录音的问题
  录音是基于JSR135的API开发的,但是有一个问题,我把一个外部设备接到插耳机的音频口,希望录制这个口的音频数据,但是结果发现用下述代码录制的是外部的声音,并不是音频口的数据。在NOKIA手机上怎么才能用J2ME把外部设备发送到音频口的数据录制下来呢?



p = Manager.createPlayer("capture://audio?encoding=pcm&rate=44100&bits=16&channels=1");

p.realize();
p.prefetch(); // new add
RecordControl rc = (RecordControl) p
.getControl("RecordControl");




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());
------解决方案--------------------
而且我发现如果我使用8位采样,p = Manager.createPlayer("capture://audio?encoding=pcm&rate=22050&bits=8&channels=1");
上述代码就会产生MediaException.
------解决方案--------------------
而且我想着devmic0是不是指定从音频口录音,我把代码改成
p = Manager.createPlayer("capture://devmic0?encoding=pcm&rate=44100&bits=16&channels=1");
会产生一个MediaException:unable to create Player with locator:capture://audio?encoding=pcm&rate=22050&bits=8&channels=1
------解决方案--------------------
我试了好几个NOKIA手机,发现他们只能录制外部的声音,而不能通过耳机口录音