2
我正在開發BlackBerry,並試圖通過不只是啓動視頻攝像頭應用來錄製視頻。黑莓錄製視頻保存0KB的文件
我可以創建Player
對象並在屏幕上創建一個顯示相機可以看到的內容的字段。我正在錄音並且工作正常 - 但是當我在RecordControl
上撥打commit()
時,文件被寫入0KB的SD卡。我一直在爲此撓頭,並且無法解決這個問題。這裏是一個開始&代碼完成了記錄:
private void displayVideoRecorder()
{
initVideoRecorder();
if (mTimeLeft == null)
{
mTimeLeft = UIFactory.createLabel("Time left: " + (mMaxVideoDuration - mCurrVideoDuration));
}
// Create a stop recording button and a listener for the saving video functionality
if (mStopRecording == null)
{
mStopRecording = UIFactory.createButtonField("Begin recording");
mStopRecording.setChangeListener(new FieldChangeListener()
{
public void fieldChanged(Field field, int context)
{
if (mRecordingVideo)
{
// Stop the messages
if (mHandlerID != -1)
{
UiApplication.getUiApplication().cancelInvokeLater(mHandlerID);
mHandlerID = -1;
}
new Runnable()
{
public void run()
{
// Save the video
stopRecordingVideo();
// Reset the flag
mRecordingVideo = false;
}
}.run();
// Return to the main page
displayFirstPage();
}
else
{
// Start recording
new Runnable()
{
public void run()
{
mRecordControl.startRecord();
mRecordingVideo = true;
// Queue a message for however long the maximum time for a video is
mHandlerID = UiApplication.getUiApplication().invokeLater(mHandler, 1000, true);
}
}.run();
// Set a flag and change the text of the button
mStopRecording.setLabel("Stop recording");
}
}
});
}
mCurrVideoDuration = 0;
mStopRecording.setLabel("Begin recording");
mTimeLeft.setText("Time left: " + (mMaxVideoDuration - mCurrVideoDuration));
// Add the video & a button to go back
getContentArea().deleteAll();
getContentArea().add(mVideoField);
getContentArea().add(mTimeLeft);
getContentArea().add(mStopRecording);
try
{
// Show what the camera can see
mPlayer.start();
}
catch (Exception e)
{
Out.p("Failed to begin video player");
Out.printStackTrace(e);
}
}
/**
* Stops recording the video and saves the file to the file system. If a video is not recording this call is ignored
*/
private void stopRecordingVideo()
{
if (mRecordingVideo)
{
try
{
mRecordingVideo = false;
// Stop recording and save the file name
mRecordControl.stopRecord();
mPlayer.stop();
mRecordControl.commit();
}
catch (Exception e)
{
Out.alert(e.toString());
}
}
}
private void initVideoRecorder()
{
try
{
Out.p("Beginning initialise of recorder");
mPlayer = Manager.createPlayer("capture://video?" + getEncodings()[0]);// "capture://video?encoding=video/3gpp");
mPlayer.addPlayerListener(new PlayerListener()
{
public void playerUpdate(Player player, String event, Object eventData)
{
Out.p("Player " + player.hashCode() + " got event " + event + ": " + eventData);
}
});
mPlayer.realize();
mVideoControl = (VideoControl) mPlayer.getControl("VideoControl");
mRecordControl = (RecordControl) mPlayer.getControl("RecordControl");
Out.p("Record Control: " + mRecordControl);
// Set where the video will record to
mRecordControl.setRecordLocation(mFilePath);
mVideoField = (Field) mVideoControl.initDisplayMode(GUIControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
// add(mVideoField);
Out.p("Video Field: " + mVideoField);
}
catch (Exception e)
{
Out.alert(e.toString());
Out.p("Failed to start recording");
displayFirstPage();
}
}
我已經按照原先沒有能夠得到它保存的實際視頻,但沒有success.Any幫助表示讚賞後,許多導遊。謝謝。