PDA

View Full Version : QMediaPlayer Questions



morpheus
25th August 2013, 13:05
I am tidying up some old code that used QSound which does not work on Linux (well as least mine it doesn't). Options->sounds sets the sound file to be played for various events, so that different ones can be used for different events, or muted by a checkbox. The code compiles with no errors and runs. The sounds for events work for a while and then they stop. I haven't been through all the code to see where the functions are called from, but when the test in the options->sound is used, they play, they play for a while when using the program and then stop. The following is my code:


m_pPlayer = new QMediaPlayer(this);
connect(m_pPlayer, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64)));
m_pPlayer->setMedia(QUrl::fromLocalFile(filename));
//Set the volume
m_pPlayer->setVolume(100);
m_pPlayer->play();
disconnect(m_pPlayer, SIGNAL(triggered(bool)), this, SLOT(play()));
// QSound::play(filename); not needed anymore as not using QSound

My questions are (remember I be an apprentice to c++ and Qt):

is this code correct for the using this/these functions?
where do I start looking for the problem (any ideas would be greatfully appreciated)?

saman_artorious
25th August 2013, 14:03
I think yes, you're code seems to be correct. By the way, do you know how to play movie with image raw data with QMediaPlayer? I still cannot find a solution to my problem. Please have a look at my pre-posted post here: http://www.qtcentre.org/threads/55824-set-raw-data-buffer-to-QMediaPlayer