-
Bug
-
Resolution: Done
-
Not Evaluated
-
1.1.3
-
None
-
Symbian S60 5th Edition
Nokia N97 mini, Nokia C6-00
The QCamera and the QMediaPlayer don't work together when both have to display their images.
My Mainwindow.ui consists of 2 Widgets, a QVideoWidget (videoWidget) and a QCameraViewFinder. Additionaly there is a QPushButton named playButton.
i'll post only the mainwindow, the complete code is attached
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QUrl> #include <QDebug> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), camera(NULL), player(NULL) { ui->setupUi(this); ui->videoWidget->hide(); player = new QMediaPlayer(this); player->setVideoOutput(ui->videoWidget); player->setMedia(QUrl::fromLocalFile("E:\\test.avi")); connect(player, SIGNAL(stateChanged(QMediaPlayer::State)), SLOT(playerStateChanged(QMediaPlayer::State))); connect(player, SIGNAL(error(QMediaPlayer::Error)), SLOT(playerError(QMediaPlayer::Error))); camera = new QCamera(this); camera->setViewfinder(ui->viewFinder); camera->start(); } MainWindow::~MainWindow() { delete ui; } void MainWindow::playerError(QMediaPlayer::Error error) { qDebug() << error << player->errorString(); } void MainWindow::on_playButton_clicked() { camera->unload(); ui->viewFinder->hide(); ui->videoWidget->show(); player->play(); } void MainWindow::playerStateChanged(QMediaPlayer::State state) { if(state == QMediaPlayer::StoppedState) { ui->videoWidget->hide(); ui->viewFinder->show(); camera->start(); } }
the expected behaviour is:
in the beginning the viewfinder is shown and the live image from the camera is displayed.
when the play button is pressed the viewfinder is hidden and the multimediaplayer plays the E:\test.avi in the now shown videowidget.
when the playback finished the videowidget is hidden and the viewfinder displays the cameraimage again.
the real behaviour is:
the viewfinder displays the live image from the camera.
when the play button is pressed the first time, the camera viewfinder is hidden the player plays only sound no video output is visible
when the playback finished the camera life image is displayed again normally
when the play button is pressed again, the camera viewfinder hides and the video plays with image as one would expect when pressing the first time.
when the playback is finished the camera does not display again, showing this message:
[Qt Message] Camera error: "Access to camera device was rejected." [Qt Message] Camera state changed: 0
if i use camera->stop() instead of unload() the mediaplayer never plays the visual part of the video and the camera works fine all the time.
the player itself does not produce any errors
I could reproduce it with the QtMobility 1.2.0 beta, too, but I have no possibility to test 1.2 final.