Mak*_*tar 11
RIM API包含用于处理音频和视频内容的JSR 135 Java Mobile Media API.
你纠正了BB知识库中的混乱.唯一的方法是浏览它,希望他们不会再次更改站点地图.
它是开发人员 - >资源 - > 知识库 - > Java API和样本 - > 音频和视频
基本上录制音频很简单:
链接:
RIM 4.6.0 API参考:包javax.microedition.media
如何 - 在BlackBerry智能手机上录制音频
如何 - 在应用程序中播放音频
如何 - 支持流式音频到媒体应用程序
如何 - 指定音频路径路由
如何收件人 - 从媒体应用程序获取媒体播放时间内容是
什么 - 支持的音频格式
什么是 - 媒体应用程序错误代码
声明了与Player,RecordControl和资源的线程:
final class VoiceNotesRecorderThread extends Thread{
private Player _player;
private RecordControl _rcontrol;
private ByteArrayOutputStream _output;
private byte _data[];
VoiceNotesRecorderThread() {}
private int getSize(){
return (_output != null ? _output.size() : 0);
}
private byte[] getVoiceNote(){
return _data;
}
}
Run Code Online (Sandbox Code Playgroud)
在Thread.run()上开始录音:
public void run() {
try {
// Create a Player that captures live audio.
_player = Manager.createPlayer("capture://audio");
_player.realize();
// Get the RecordControl, set the record stream,
_rcontrol = (RecordControl)_player.getControl("RecordControl");
//Create a ByteArrayOutputStream to capture the audio stream.
_output = new ByteArrayOutputStream();
_rcontrol.setRecordStream(_output);
_rcontrol.startRecord();
_player.start();
} catch (final Exception e) {
UiApplication.getUiApplication().invokeAndWait(new Runnable() {
public void run() {
Dialog.inform(e.toString());
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
并且在thread.stop()上停止录制:
public void stop() {
try {
//Stop recording, capture data from the OutputStream,
//close the OutputStream and player.
_rcontrol.commit();
_data = _output.toByteArray();
_output.close();
_player.close();
} catch (Exception e) {
synchronized (UiApplication.getEventLock()) {
Dialog.inform(e.toString());
}
}
}
Run Code Online (Sandbox Code Playgroud)
在录制结束时,您将使用特定音频格式的数据填充输出流.因此,要处理或采样它,您必须解码此音频流.
谈论飞行处理,这将更复杂.您必须在录制期间读取输出流而不记录提交.因此需要解决几个问题:
也可能有用:
java.net:Vikram Goyal在Java ME中的流内容实验