Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. I want to run .mp3 file using phonon namespace

I want to run .mp3 file using phonon namespace

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Himanshupradhan
    wrote on last edited by
    #1

    Hi, i am learning Qt, i want to run .mp3 file, so that i write a basic code, but it is giving error,can you check it
    @
    #include <QtGui>
    #include<phonon/MediaNode>
    #include<phonon/MediaObject>
    #include<phonon/MediaSource>
    #include<phonon/AudioOutput>
    #include<phonon/Path>

    int main(int argv, char **args)
    {
    QApplication app(argv, args);
    app.setApplicationName("Music Player");

    // The below portion of code is to run .mp3 file
    Phonon::MediaObject *mediaobject = new Phonon::MediaObject;
    QString filename("C:\Users\Public\Music\Sample Music");
    mediaobject->setCurrentSource(filename);
    Phonon::AudioOutput *audio = new Phonon::AudioOutput;
    Phonon::createPath(mediaobject,audio);
    mediaobject->play();
    //..............................................................
    
    
    return app.exec&#40;&#41;;
    

    }
    @

    Edit: please use @ tags around your code sections; Andre

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      If you have a problem, please be specific on what problem you have. In this case, don't just say "is giving error", but tell us about the specific error. In this case, we also need information on your platform (windows? linunx? mac? some other platform? what version?) and your Qt version.

      One thing that is immediately obvious from your code though, is that the path you give is not going to work (line 18). Backslashes need to be escaped in strings. However, in Qt, you can just use forward slashes instead.

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Himanshupradhan
        wrote on last edited by
        #3

        i am using windows platform, and Qt SDK 1.1.4.

        i have tried with forwrd slash and these error came.

        error 1:- C:\MeeGoSDK_1.2\Himanshu\Test\Music-build-desktop-Desktop-MinGW_Debug..\Music\main.cpp:17: error: undefined reference to `_imp___ZN6Phonon11MediaObjectC1EP7QObject'

        error 2:- C:\MeeGoSDK_1.2\Himanshu\Test\Music-build-desktop-Desktop-MinGW_Debug..\Music\main.cpp:19: error: undefined reference to `_imp___ZN6Phonon11MediaSourceC1ERK7QString'

        errror 3:- C:\MeeGoSDK_1.2\Himanshu\Test\Music-build-desktop-Desktop-MinGW_Debug..\Music\main.cpp:19: error: undefined reference to `_imp___ZN6Phonon11MediaSourceD1Ev'

        error 4:- C:\MeeGoSDK_1.2\Himanshu\Test\Music-build-desktop-Desktop-MinGW_Debug..\Music\main.cpp:19: error: undefined reference to `_imp___ZN6Phonon11MediaSourceD1Ev'

        is this api is also needed or not "mediaobject = Phonon::createPlayer(Phonon::MusicCategory,Phonon::MediaSource("C:/Users/Public/Music/Sample Music"));"

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          Are you actually linking to the phonon libs?

          1 Reply Last reply
          0
          • H Offline
            H Offline
            Himanshupradhan
            wrote on last edited by
            #5

            thanks for reply, yes i was not linking phonon library in my .pro file, when i use this syntax QT +=phonon in my .pro file it starts working

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved