Qt Android MediaPlayer NoMEdia
-
I have the strange situation that on any Android platform i try to play a movie, but nothing happens.
The code is simple:
videoItem = new QGraphicsVideoItem;
videoItem->setSize(QSizeF(MainView::getInstance()->geometry().width(), MainView::getInstance()->geometry().height()));
MainView::getInstance()->scene()->addItem(videoItem);
mediaPlayer = new QMediaPlayer;
mediaPlayer->setVideoOutput(videoItem);
QFile movie(movieName);
if (!movie.exists())
qDebug() << QTime::currentTime().toString("HH:mm:ss:zzz") << "info_player" << "Movie does not exist" << movieName;
else
{
mediaPlayer->setMedia(<movieName>);
mediaPlayer->play();
}I have added the signals stateChanged and mediaStatusChanged. A don't get any signal either.
When I have added the statement:
qDebug() << QTime::currentTime().toString("HH:mm:ss:zzz") << "info_player" << mediaPlayer->mediaStatus();I get the message in my log: QMediaPlayer::NoMedia
On windows this works wonderfull.What's wrong?
Do I need to add something in the Android Manifest?Please help.
-
I came a bit further.
When I create a QVideoWidget as a child of QWidget
and create the QMediaPlayer as:
new QMediaPlayer(widget)
I get the sound of the movie.As soon as I add
mediaPlayer->setVideoOutput(widget);
I get the NoMedia result. -
I have solved the issue myself.
I added the Qt kibraries in the apk file. That shouldn't. Ministro should download them on the tablet.Then I got the eeror: Illegal state.
You have to create the mediaplayer with:
mediaPlayer = new QMediaPlayer(videoItem);After that the player started to play the movies