1

In a mobile phone application, I need to play a sound file (mp3 or wav) embedded in a data file.

Currently I need to extract the file to the SDCARD and it is quite slow.

However, in Android, I can play it inside a data file without extracting.

I requested this feature to the Qt team about 2 years ago but it seems that this function still not available.

I think I should do some streaming from the data file but lack the knowledge. Anybody has some code to enlighten me?

xuxiang
  • 45
  • 1
  • 6
  • For those of us who don't do mobile Qt...what are you using using to play the file at present? Just QSound? Would your mobile phone categorize as a "Symbian" build? http://doc.qt.nokia.com/latest/qsound.html – HostileFork says dont trust SE Nov 29 '11 at 02:59
  • Hi, currently I use the QMediaPlayer (require QtMobility I think) to play the mp3/wav file. The primary target is Symbian but it also run on N900 currently. – xuxiang Nov 29 '11 at 03:01

1 Answers1

0

I actually do not use Qt for mobile application development, but I think you can embed your audio file into resources and then just play it by Phonon module. The example how you can do this in a simple console application is below (":/fileName.mp3" is the path to the audio in the resource file). Phonon is a cross-platform multimedia framework and you also have resources on mobile platforms.

#include <QtCore/QCoreApplication>
#include <phonon>

using namespace Phonon;

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    MediaObject *music =
    createPlayer(MusicCategory,MediaSource(":/fileName.mp3"));
    music->play();

    return 0;
}
vitakot
  • 3,786
  • 4
  • 27
  • 59
  • Hi, thanks for your suggestion, but I can't do that because I need to read a multimedia data file which is created by a third party application. – xuxiang Nov 29 '11 at 03:41