2013-06-01 51 views
4

我需要以特定分辨率錄製視頻(儘可能最少)。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=erroreventData=2PlayerListener.playerUpdate(Player player, String event, Object eventData)方法

描述爲eventData=2我發現here

無效的參數:參數與一個無效的值指定。

有人可以解釋我爲什麼我的參數不正確嗎?

+1

關於空對象,[看看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

回答

2

用戶可以修改錄音設置 - 在高端手機上有三種不同的質量等級,但錄音機默認爲最高質量。我試圖將其設置爲中等質量等級 - 640x480,但尚未能找到一種方法來實現這一點。

由於您要求最低的質量,您可能會有一些運氣。您可以指定「彩信」質量,並且視頻錄製質量非常低,這正是您想要的。

我引用「RIM blackberry Record 3GP video」這說明將&mode=mms添加到播放器字符串將給你彩信質量。不幸的是,它似乎也將持續時間限制爲30秒。

+0

你有*確切* 9000聲譽:O – Doorknob

+0

@門把嘿,是的,我確實。沒有更多的讚揚! –

+0

我試過'&mode = mms'但是這對我沒有幫助。我更新了更多細節的問題 – CAMOBAP

相關問題