Я разрабатываю для BlackBerry и пытаюсь записать видео, а не просто запускать приложение для видеокамеры.BlackBerry Recording Video Сохраняет файл 0KB
Я могу создать объект Player
и создать поле на экране, которое отображает то, что может видеть камера. Я записываю и отлично работает, но когда я звоню commit()
на RecordControl
, файл записывается на SD-карту 0 КБ. Я уже немного почесываю голову на это некоторое время и не могу решить эту проблему. Вот код, который начинается & закончил запись:
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();
}
}
Я следовал много руководств после первоначально не в состоянии получить его, чтобы сохранить фактическое видео, но без какого-последовательного успеха помощи не ценятся. Благодарю.