我需要以特定分辨率錄製視頻(儘可能最少)。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