defaultServiceProvider::requestService(): no service found for - "com.nokia.qt.mediaplayer"
I am using the QMediaPlayer to play a mp3 file, but get this error. How to resolve this?
defaultServiceProvider::requestService(): no service found for - "com.nokia.qt.mediaplayer"
I am using the QMediaPlayer to play a mp3 file, but get this error. How to resolve this?
It says that it will work on the real device, not on simulator. but why on real device, my still does not work. Here is my code:
Does play sound need any capability?
I debuged, and get QMediaPlayer::InvalidMedia, why? Is my path not correct or the mp3 file is not correct?
Sound::Sound(QWidget *parent) :
QWidget(parent)
{
playSound = new QPushButton(this);
playSound->setText("Play Sound");
playSound->setFixedSize(QSize(200,100));
playSound->setGeometry(80,200, 200,100);
mPlayer = new QMediaPlayer(this);
QString mypath("C:\\QT_workspace\\second\\3days.mp3"); //already put this file in the C drive on the phone
// QString mypath(":\\3days.mp3");
QUrl mySoundUrl = QUrl::fromLocalFile(mypath.toAscii());
QMediaResource myResource(mySoundUrl, "audio");
QMediaContent mymedia(myResource);
mPlayer->setMedia(mymedia);
mPlayer->setVolume(80);
QObject::connect(mPlayer, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(statusChanged(QMediaPlayer::MediaStatus)));
QObject::connect(mPlayer, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(stateChanged(QMediaPlayer::State)));
QObject::connect(playSound,SIGNAL(clicked()),this,SLOT(on_playbutton_clicked()));
// Symbian specific code
#ifdef Q_OS_SYMBIAN
#endif
}
void Sound:n_playbutton_clicked()
{
mPlayer->play();
}
void Sound::statusChanged(QMediaPlayer::MediaStatus status) {
switch(status) {
case QMediaPlayer::LoadedMedia:
mPlayer->play();
break;
case QMediaPlayer::LoadingMedia:
mPlayer->play();
default:
break;
}
}
void Sound::stateChanged(QMediaPlayer::State state) {
switch(state) {
case QMediaPlayer::PlayingState:
qDebug() << "now playing";
break;
case QMediaPlayer::StoppedState:
qDebug() << "now stopped";
break;
case QMediaPlayer::PausedState:
qDebug() << "now paused";
break;
}
}
Last edited by xhsoldier; 2010-11-29 at 05:30.