Important: Please read the Qt Code of Conduct -

Append audio file to html

  • Hi,

    I used the code below to play audio file but instead of "mMedia->play()", I would like to append the audio file as html tag in a html file. After several search online, I came to the understanding that Qt 4.8 library doesn't support html5 tag and audio tag is part of html5. Can anyone suggest a way around this problem?

    @void MainWindow::InsertAudio()
    Phonon::MediaObject* mMedia = new Phonon::MediaObject(this);
    Phonon::AudioOutput* mAudio = new Phonon::AudioOutput(Phonon::MusicCategory, this);
    Phonon::createPath(mMedia, mAudio);
    mMedia->setCurrentSource(QFileDialog::getOpenFileName(0,QString("Select audio file"),QString()));


  • Maybe you can write something like this in your website:

    <embed type="audio/x-midi" autostart="false" src="breeze.mid" width="300" height="200"></embed><br>
    <a >Starten</a>

    Hope this helps.

    EDIT: The js was removed from the link (please remove spaces)
    java <remove newline>
    script : document . e m b e d s [ 0 ] . p l a y ( )

    Sorry for this stupid formatting but the editor will remove it otherwise.

  • Thank you for your reply. There is no existing website. The Qt application I'm working on is suppose to be wysiwyg html editor and I need to be able to insert audio. The output is suppose to be html. What is your advice on how to achieve this?

  • If you want to play the audio in the wysiwyg you can do it as you described above and for the output you can use the html above. You have to provide the audio file on your webserver then as well of course.

Log in to reply