Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Cant play sound on Windows 7 [Solved]

    General and Desktop
    3
    11
    5022
    Loading More Posts
    • 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.
    • F
      ferrazrafael last edited by

      Im using this code to play a sound file on linux, and it work. But in windows 7 it doesnt. Any one knows why?
      @
      Phonon::MediaObject *mediaObject = Phonon::createPlayer(Phonon::NoCategory, Phonon::MediaSource("sound.ogg"));
      mediaObject->play();
      delete mediaObject;
      @

      1 Reply Last reply Reply Quote 0
      • M
        mohsen last edited by

        do you have "ogg" multimedia codec installed on your windows?

        1 Reply Last reply Reply Quote 0
        • A
          andre last edited by

          Do you expect mediaObject to live long enough this way to actually do anything? You create the player, and then immediately destroy it again. I would not expect that to work...

          1 Reply Last reply Reply Quote 0
          • F
            ferrazrafael last edited by

            Yes I have ogg, and I tested with .wav and dont work.
            Andre, This is just a simplified test case, in my real code delete is not so close from createplayer().

            1 Reply Last reply Reply Quote 0
            • A
              andre last edited by

              Sorry, hard to judge your real problem without seeing your real code.

              1 Reply Last reply Reply Quote 0
              • F
                ferrazrafael last edited by

                I discovered why isnt working, Im using .qrc file to store my audio files and playing by it like this

                @
                Phonon::MediaObject *mediaObject = Phonon::createPlayer(Phonon::NoCategory,
                Phonon::MediaSource(":/sound.ogg"));
                mediaObject->play();
                @

                In linux it work, in windows it only work if I set the MediaSource like this

                @
                Phonon::MediaObject *mediaObject = Phonon::createPlayer(Phonon::NoCategory, Phonon::MediaSource("./sound.ogg"));
                @

                1 Reply Last reply Reply Quote 0
                • A
                  andre last edited by

                  Thanks for reporting back with your solution. Could you please mark the topic as solved by editing the topic title and adding [Solved]? You can do that pressing the edit link next to your first posting in the topic.

                  1 Reply Last reply Reply Quote 0
                  • F
                    ferrazrafael last edited by

                    this dont need to be reported as a bug? since it work in on way on windows and another in linux?

                    1 Reply Last reply Reply Quote 0
                    • A
                      andre last edited by

                      You could report it, yes. That might be a good idea.
                      It is a weird issue. The latter version should not use the resource at all.

                      1 Reply Last reply Reply Quote 0
                      • F
                        ferrazrafael last edited by

                        This is a pity, I liked the way qt make sounds builtin the app

                        1 Reply Last reply Reply Quote 0
                        • M
                          mohsen last edited by

                          it should be fixed. not good idea on using #ifdef OS for a syntax like this!

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post