私のコードは以下のとおりです-ブラックベリーのウェブサイトからドキュメントを試しましたが、オーディオファイルは作成されません。この問題を解決する方法は?前もって感謝します。
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.component.*;
import java.lang.*;
import javax.microedition.io.Connector;
import javax.microedition.io.file.FileConnection;
import javax.microedition.media.*;
import javax.microedition.media.Manager;
import java.io.*;
import javax.microedition.media.control.*;
public class AudioRecording extends UiApplication
{
public static void main(String[] args)
{
AudioRecording app = new AudioRecording();
app.enterEventDispatcher();
}
public AudioRecording()
{
pushScreen(new AudioRecordingDemoScreen());
}
private class AudioRecordingDemoScreen extends MainScreen
{
private AudioRecorderThread _recorderThread;
ByteArrayOutputStream bt;
DataOutputStream ot;
public AudioRecordingDemoScreen()
{
//setTitle("Audio recording demo");
addMenuItem(new StartRecording());
addMenuItem(new StopRecording());
}
private class StartRecording extends MenuItem
{
public StartRecording()
{
super("Start recording", 0, 100);
}
public void run()
{
try
{
AudioRecorderThread newRecorderThread = new AudioRecorderThread();
newRecorderThread.start();
_recorderThread = newRecorderThread;
}
catch (Exception e)
{
Dialog.alert(e.toString());
}
}
}
private class StopRecording extends MenuItem
{
public StopRecording()
{
super("Stop recording", 0, 100);
}
public void run()
{
try
{
if (_recorderThread != null)
{
_recorderThread.stop();
}
}
catch (Exception e)
{
Dialog.alert(e.toString());
}
}
}
private class AudioRecorderThread extends Thread implements javax.microedition.media.PlayerListener
{
private Player _player;
private RecordControl _recordControl;
AudioRecorderThread()
{
}
public void run()
{
try
{
_player = javax.microedition.media.Manager.createPlayer("capture://audio?encoding=amr");
_player.addPlayerListener(this);
_player.realize();
_recordControl = (RecordControl) _player.getControl( "RecordControl" );
FileConnection fc = (FileConnection)Connector.open("file:///Device Memory/home/user/music/recordingFile.amr", Connector.READ_WRITE );
if(!fc.exists()){
fc.create();
}
ot = fc.openDataOutputStream();
_recordControl.setRecordStream(ot);
_recordControl.startRecord();
_player.start();
}
catch( IOException e )
{
Dialog.alert(e.toString());
}
catch( MediaException e )
{
Dialog.alert(e.toString());
}
}
public void stop()
{
/* if (_player != null)
{
_player.close();
_player = null;
}
if (_recordControl != null)
{
_recordControl.stopRecord();*/
try
{
_recordControl.commit();
}
catch (Exception e)
{
Dialog.alert(e.toString());
}
/* _recordControl = null;
} */
}
public void playerUpdate(Player player, String event, Object eventData)
{
Dialog.alert("Player " + player.hashCode() + " got event " + event + ": " + eventData);
}
}
}
}
そのファイルを作成していません。この問題を解決する方法