Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9114743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:16:07+00:00 2026-06-17T04:16:07+00:00

In Qt4 I used to use QT += multimedia phonon //… #include <Phonon> //…

  • 0

In Qt4 I used to use

QT += multimedia phonon
//...
#include <Phonon>
//...
        Phonon::MediaObject *mediaObject = Phonon::createPlayer(Phonon::NoCategory, Phonon::MediaSource(QUrl("./assets/audio/window_appear.wav")));
        //   "\"" + Qdir().absolutePath() + "/audio/click.wav" + "\""
        mediaObject->play();

and it all worked fine. But now Phonon is not supported in Qt 5. So I wonder – how can I play media files such as sound in Qt5?

Using WebKit? (It is entirely possible but looks kind of bad from many points of view)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:16:09+00:00Added an answer on June 17, 2026 at 4:16 am

    The Qt developers started to reduce their efforts on Phonon integration already during the later versions of Qt4, focussing on the Qt Multimedia and Qt Mobility modules instead. Though they did still support Phonon.

    As you say, as of Qt5, Phonon is no longer supported. So look into Qt Multimedia instead, especially QAudioOutput.

    As listed within their documentation under “Detailed Description”, playing an audio file looks something like this:

    QFile inputFile;     // class member.
    QAudioOutput* audio; // class member.
    inputFile.setFileName("/tmp/test.raw");
    inputFile.open(QIODevice::ReadOnly);
    
    QAudioFormat format;
    // Set up the format, eg.
    format.setFrequency(8000);
    format.setChannels(1);
    format.setSampleSize(8);
    format.setCodec("audio/pcm");
    format.setByteOrder(QAudioFormat::LittleEndian);
    format.setSampleType(QAudioFormat::UnSignedInt);
    
    QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
    if (!info.isFormatSupported(format)) {
        qWarning()<<"raw audio format not supported by backend, cannot play audio.";
        return;
    }
    
    audio = new QAudioOutput(format, this);
    
    connect(audio,SIGNAL(stateChanged(QAudio::State)),SLOT(finishedPlaying(QAudio::State)));
     audio->start(&inputFile);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am slowly getting used to using the Qt4 GUI framework. In a project
Here's the thing: In my Qt4.6-Project, I use a SQLite-Database. This database shouldn't be
I have a C++ project that is using QT4. I've used QT Designer to
I would like to use Autotools and QT4 together. For this i would like
Qt4 has support for Drag & Drop actions and I've used them like in
In QT4.5, I use a QTableWidget, and I have connected the signal QTableWidget::itemClicked() to
What's the best way to use QT4's QItemDelegate to show thumbnails for images in
I'm using Qt4.8 on OSX Leopard and instead of qmake + QtCreator I want
Create a simple Qt4 Gui Application, surround the window construction and show commands in
I'm using C++ with QT4 for this. And when I try to send large

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.