我需要以特定分辨率录制视频(尽可能最少)。Blackberry:如何在录制前设置视频分辨率
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
如何为录制视频的分辨率指定?
P.S.黑莓OS 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
我发现here:
无效的参数:参数与一个无效的值指定。
有人可以解释我为什么我的参数不正确吗?
关于空对象,[看看Smith先生的答案在这里(http://stackoverflow.com/a/9666104/119114)这也指向[这个BlackBerry文档](http://supportforums.blackberry.com/t5/Java-Development/Advanced-Multimedia-Supplement-API-What-s-Supported/ta-p/770659),其中说,他们没有实现'setVideoResolution()',因为你不幸发现了。 – Nate