我需要以特定分辨率录制视频(尽可能少)。
private void startRecording(Player player, net.rim.device.api.ui.Manager parentManager)
{
try
{
if (player == null)
{
player = javax.microedition.media.Manager.createPlayer("capture://video?encoding=video/3gpp");
player.addPlayerListener(this);
player.realize();
RecordControl recordControl = (RecordControl) player.getControl("RecordControl");
VideoControl videoControl = (VideoControl) player.getControl("VideoControl");
if (videoControl != null)
{
final Field videoField = (Field)videoControl.initDisplayMode( VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field" );
try
{
videoControl.setDisplaySize(1, 1);
}catch(Exception e)
{
System.out.println(e);
}
videoControl.setVisible(true);
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run()
{
if(parentManager != null)
{
if(videoField.getIndex() == -1)
{
parentManager.insert(videoField, 1);
}
}
}
});
}
}
// here i get null
CameraControl cameraControl = (CameraControl) player.getControl("CameraControl");
int[] resolutions = cameraControl.getSupportedVideoResolutions();
cameraControl.setVideoResolution(resolutions.length / 2 - 1);
recordControl.setRecordLocation("test.3gp");\
recordControl.startRecord();
player.start();
}catch(Exception e)
{
System.out.println(e);
}
}
但由于某种原因(CameraControl) player.getControl("CameraControl");
返回null
如何指定录制视频的分辨率?
PS 黑莓操作系统 5.0,火炬 9800
更新:
如果我使用
capture://video?encoding=video/3gpp&mode=mms
或者
capture://video?encoding=video/3gpp&width=240&height=180&video_codec=MPEG-4&audio_codec=AMR
我得到event=error
了方法eventData=2
PlayerListener.playerUpdate(Player player, String event, Object eventData)
eventData=2
我在这里找到的描述:
无效参数:指定的参数值无效。
有人可以解释为什么我的参数不正确吗?