How to play Audio file in Android QT?

2.3k Views Asked by At

i developed my application in QT, i am trying to port for android. my application working fine in android with few issues. the main issue is, i am not able to play the audio file when i am trying to put the audio file play Code i am getting error

QSound::play(FilePath);

Error: : -1: error: error: cannot find -lQtMultimediaKit D:\Projects\test\demo.cpp:996: error: undefined reference to 'QSound::play(QString const&)'

my config: QT 4.8,QT Creator 2.5.83 and necessitas and windows XP

i am able to include the QSound Header file and using intellisense to type the QSound::Play no issue while typing when i am getting error on compilation. so i tried to look into the source folder and i found QSound.h header also.

How to play the Audio file in Android using QT?

4

There are 4 best solutions below

0
On

this works for me

file .pro

QTPLUGIN += qtaudio_coreaudio
QT += androidextras
    QT += widgets
    QT += quickcontrols2

file in Resources:

player2->setMedia(QUrl("qrc:/new/prefix1/folder_x/file.mp3"));
    player2->play();
0
On

While the support of Audio for Android in QT is there, it's a journey through hell with the current release. If you want it stable in the end you'll end-up searching for external libraries anyway Take a look here

0
On

Stumblend in this one while searching info, this looks useful: http://qt-project.org/doc/qt-5/qml-qtmultimedia-mediaplayer.html

1
On

in may case it works properly with no errors my code:

player->setMedia(QUrl("qrc:/new/prefix1/1.mp3"));    
// ok it works on windows  
//also works on android