我想在我的应用程序中录制并保存视频,论坛上没有很多关于此的信息。
我不想像“Invoke.invokeApplication(Invoke.APP_TYPE_CAMERA, new CameraArguments());”那样调用相机
下面的代码片段给了我一个空白屏幕http://docs.blackberry.com/en/developers/deliverables/17968/Record_video_to_a_file_in_a_BB_device_app_1222784_11.jsp
我已经开始、停止和保存视频,当我尝试播放视频时显示“不支持格式”,有没有办法获得所有支持的格式,是否有所有视频格式的列表?我的代码:
public class MyScreen extends MainScreen{
String PATH;
RecordControl _recordControl;
Player _player;
MenuItem RecordVideo;
MenuItem StopVideo;
MenuItem SaveVideo;
public MyScreen() {
try {
_player = javax.microedition.media.Manager.createPlayer("capture://video?encoding=video/3gpp");
_player.realize();
VideoControl videoControl = (VideoControl) _player.getControl("VideoControl");
_recordControl = (RecordControl) _player.getControl( "RecordControl" );
Field videoField = (Field) videoControl.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
try{
videoControl.setDisplaySize( Display.getWidth(), Display.getHeight() );
}catch( MediaException me ){
Dialog.alert("Display size not supported");
}
add(videoField);
_recordControl.setRecordLocation("file:///store/home/user/videos/VideoRecordingTest.3gpp" );
_player.start();
_recordControl.startRecord();
}catch( IOException e ){
Dialog.alert(e.toString());
} catch( MediaException e ){
Dialog.alert(e.toString());
}
RecordVideo = new MenuItem("Start Recording", 0, 0){
public void run() {
try {
_player.start();
_recordControl.startRecord();
} catch (MediaException e) {
Dialog.alert("Error Starting recording");
e.printStackTrace();
}
}
};
StopVideo = new MenuItem("Stop Recording", 0, 0){
public void run() {
try {
_player.stop();
} catch (MediaException e) {
Dialog.alert("Error Stopping recording");
e.printStackTrace();
}
}
};
SaveVideo = new MenuItem("Save Video", 0, 0){
public void run() {
try {
// Create an invocation instance with the specified URL where the file type is one of the media types supported by the media player.
Invocation invocation = new Invocation("file:///SDCard/BlackBerry/music/001.mp3");
// Get the Registry object using the class name of the application
Registry _registry=Registry.getRegistry(Application.getApplication().getClass().getName());
//Invoke the content handler.
_registry.invoke(invocation);
} catch (IOException e)
{ }
}
};
}
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;
}
}
protected void makeMenu(Menu menu, int instance) {
ContextMenu contextMenu = ContextMenu.getInstance();
contextMenu.setTarget(this);
contextMenu.clear();
this.makeContextMenu(contextMenu);
menu.deleteAll();
menu.add(contextMenu);
}
public void makeContextMenu(ContextMenu contextMenu) {
contextMenu.addItem(MenuItem.separator(32));
contextMenu.addItem(RecordVideo);
contextMenu.addItem(StopVideo);
contextMenu.addItem(SaveVideo);
}
}