void RecorderManager::startRecord(const QString &recorder, const AbstractRecorder::Data &data) { if (m_recorder) { m_manager->unloadPlugin(m_recorder); } m_recorder = static_cast<AbstractRecorder*>(m_manager->loadPlugin(recorder)); if (!m_recorder) { recorderError(i18n("Cannot load Recorder %1.", recorder)); return; } else if (data.outputFile.isEmpty()) { recorderError(i18n("No output file specified.")); return; } connect(m_recorder, SIGNAL(error(QString)), this, SLOT(recorderError(QString))); connect(m_recorder, SIGNAL(outputFileChanged(QString)), this, SIGNAL(fileChanged(QString))); connect(m_recorder, SIGNAL(status(QString)), this, SIGNAL(status(QString))); connect(m_recorder, SIGNAL(finished(AbstractRecorder::ExitStatus)), this, SLOT(recorderFinished(AbstractRecorder::ExitStatus))); connect(m_recorder, SIGNAL(stateChanged(AbstractRecorder::State)), this, SIGNAL(stateChanged(AbstractRecorder::State))); m_recorder->record(data); }
VideoRecorder::VideoRecorder(QDeclarativeItem *parent) : QDeclarativeItem(parent) { m_camera = new QCamera(this); connect(m_camera, SIGNAL(stateChanged(QCamera::State)), SLOT(cameraStateChanged(QCamera::State))); connect(m_camera, SIGNAL(statusChanged(QCamera::Status)), SLOT(cameraStatusChanged(QCamera::Status))); connect(m_camera, SIGNAL(error(QCamera::Error)), SLOT(cameraError(QCamera::Error))); m_viewFinder = new QGraphicsVideoItem(this); m_viewFinder->setAspectRatioMode(Qt::IgnoreAspectRatio); m_camera->setViewfinder(m_viewFinder); m_camera->setCaptureMode(QCamera::CaptureVideo); m_recorder = new QMediaRecorder(m_camera, this); connect(m_recorder, SIGNAL(stateChanged(QMediaRecorder::State)), SLOT(recorderStateChanged(QMediaRecorder::State))); connect(m_recorder, SIGNAL(error(QMediaRecorder::Error)), SLOT(recorderError(QMediaRecorder::Error))); connect(m_recorder, SIGNAL(durationChanged(qint64)), SLOT(videoDurationChanged(qint64))); }