Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Unable to play audio from Qt



  • Hello I'm using Qt 5.9.6 on beagleboard-x15

    I'm able to play audio using aplay <filepath.wav>
    aplay -l list my available soundcard
    While trying to play audio using Qt as provided on QMediaPlayer it is not playing
    Qt can detect my soundcard using below method

        foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) {
            qDebug() << "Device name: " << deviceInfo.deviceName() ;
        } 
        qDebug() << "Default Output" << QAudioDeviceInfo::defaultOutputDevice().deviceName();
    
    

    Where Default Output shows null

    Here is my method how i'm trying to play audio file

        tMediaPlayer = new QMediaPlayer(this);
    
        tMediaPlayer->setMedia(QUrl::fromLocalFile("file:/home/root/audio/instrument.wav"));
        connect(tMediaPlayer, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64)));
        tMediaPlayer->setVolume(90);
        tMediaPlayer->play();
    

    Even tMediaPlayer->error() return NoError


  • Lifetime Qt Champion

    Hi,

    What if you remove the file: prefix ? There's no need for it, fromLocalFile takes a normal path.



  • @jigarp Is Qmediaplayer play other format of audio example .mp3 on your system?


Log in to reply