Playing sound file in mobile using QT



  • Hi,

    I am just trying to play a sound file in my mobile application using QMediaPlayer.
    I have included the sound file in my project using Qt Resource file.

    While executing mediaplayer state changes to loading & then directly to invalid media.
    I have tried midi,mp3 and wave files.

    My code is like this:

    @
    {
    player = new QMediaPlayer(this);
    connect(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(statusChanged(QMediaPlayer::MediaStatus)));
    player->setMedia(QMediaContent(QUrl(":IngameTheme.mid")));
    player->play();
    }

    void playSound::statusChanged(QMediaPlayer::MediaStatus status)
    {
    qDebug() <<"In status changed "<<status;
    switch (status)
    {
    case QMediaPlayer::LoadedMedia:
    qDebug() <<"media loaded ";
    player->play();
    qDebug()<<"playerstatus "<<player->PlayingState;----
    break;
    case QMediaPlayer::InvalidMedia:
    qDebug() <<"Invadid media ";
    break;
    default:
    break;
    }
    }
    @

    Please help me to play a sound in handset from a file.
    Thanks in advance!!!

    [EDIT: code formatting, Volker]



  • I think it's a known issue that Qt Multimedia classes can't play from Qt resources (at least on Symbian). You need to deploy the file separately from your application rather than having it compiled in, then use QUrl::fromLocalFile().

    The most active community for Symbian development with Qt is on the Forum Nokia discussion boards - this kind of question would probably get answered in less than an hour. :-)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.