Important: Please read the Qt Code of Conduct -

Cant play sound on Windows 7 [Solved]

  • 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"));
    delete mediaObject;

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

  • 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...

  • 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().

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

  • 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,

    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"));

  • 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.

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

  • 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.

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

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

Log in to reply