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. Cant play sound on Windows 7 [Solved]
QtWS25 Last Chance

Cant play sound on Windows 7 [Solved]

Scheduled Pinned Locked Moved General and Desktop
11 Posts 3 Posters 5.5k Views
  • 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 Offline
    F Offline
    ferrazrafael
    wrote on last edited by
    #1

    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
    0
    • M Offline
      M Offline
      mohsen
      wrote on last edited by
      #2

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

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

        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
        0
        • F Offline
          F Offline
          ferrazrafael
          wrote on last edited by
          #4

          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
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0
            • F Offline
              F Offline
              ferrazrafael
              wrote on last edited by
              #6

              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
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #7

                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
                0
                • F Offline
                  F Offline
                  ferrazrafael
                  wrote on last edited by
                  #8

                  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
                  0
                  • A Offline
                    A Offline
                    andre
                    wrote on last edited by
                    #9

                    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
                    0
                    • F Offline
                      F Offline
                      ferrazrafael
                      wrote on last edited by
                      #10

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

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mohsen
                        wrote on last edited by
                        #11

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

                        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