-1
我想在我的應用程序中錄製amd視頻,在論壇上沒有很多關於此的信息。在黑莓應用程序中錄製視頻
我不想調用相機像「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);
}
}
人,你保存菜單項沒有真正節省以及它正試圖打開一些無關的視頻文件。我寧願看到乾淨的代碼沒有評論部分 –