Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Playing sound file in mobile using QT
Forum Updated to NodeBB v4.3 + New Features

Playing sound file in mobile using QT

Scheduled Pinned Locked Moved Mobile and Embedded
2 Posts 2 Posters 3.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    preeti
    wrote on last edited by
    #1

    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]

    1 Reply Last reply
    0
    • M Offline
      M Offline
      m_p_wilcox
      wrote on last edited by
      #2

      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. :-)

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved