Android: restart camera viewfinder after a recorder error.
Change-Id: I33f083fda5c10cfb997a21100c0ec3d4a314aee0 Reviewed-by: Christian Stromme <christian.stromme@digia.com>
This commit is contained in:
committed by
The Qt Project
parent
cd0533166f
commit
8463aae9c0
@@ -225,13 +225,13 @@ bool QAndroidCaptureSession::start()
|
||||
|
||||
if (!m_mediaRecorder->prepare()) {
|
||||
emit error(QMediaRecorder::FormatError, QLatin1String("Unable to prepare the media recorder."));
|
||||
setStatus(QMediaRecorder::UnloadedStatus);
|
||||
restartViewfinder();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_mediaRecorder->start()) {
|
||||
emit error(QMediaRecorder::FormatError, QLatin1String("Unable to start the media recorder."));
|
||||
setStatus(QMediaRecorder::UnloadedStatus);
|
||||
restartViewfinder();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -258,17 +258,15 @@ void QAndroidCaptureSession::stop(bool error)
|
||||
updateDuration();
|
||||
m_elapsedTime.invalidate();
|
||||
|
||||
if (m_cameraSession) {
|
||||
m_cameraSession->camera()->reconnect();
|
||||
// Viewport needs to be restarted
|
||||
m_cameraSession->camera()->startPreview();
|
||||
m_cameraSession->setReadyForCapture(true);
|
||||
}
|
||||
|
||||
m_mediaRecorder->release();
|
||||
delete m_mediaRecorder;
|
||||
m_mediaRecorder = 0;
|
||||
|
||||
if (m_cameraSession) {
|
||||
// Viewport needs to be restarted after recording
|
||||
restartViewfinder();
|
||||
}
|
||||
|
||||
if (!error) {
|
||||
// if the media is saved into the standard media location, register it
|
||||
// with the Android media scanner so it appears immediately in apps
|
||||
@@ -426,6 +424,13 @@ void QAndroidCaptureSession::updateViewfinder()
|
||||
m_resolutionDirty = false;
|
||||
}
|
||||
|
||||
void QAndroidCaptureSession::restartViewfinder()
|
||||
{
|
||||
m_cameraSession->camera()->reconnect();
|
||||
m_cameraSession->camera()->startPreview();
|
||||
m_cameraSession->setReadyForCapture(true);
|
||||
}
|
||||
|
||||
void QAndroidCaptureSession::updateDuration()
|
||||
{
|
||||
if (m_elapsedTime.isValid())
|
||||
|
||||
@@ -144,6 +144,7 @@ private:
|
||||
void setStatus(QMediaRecorder::Status status);
|
||||
|
||||
void updateViewfinder();
|
||||
void restartViewfinder();
|
||||
|
||||
JMediaRecorder *m_mediaRecorder;
|
||||
QAndroidCameraSession *m_cameraSession;
|
||||
|
||||
Reference in New Issue
Block a user