November 4, 2011

ferrazrafael ferrazrafael
Lab Rat
13 posts

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?

  1. Phonon::MediaObject *mediaObject = Phonon::createPlayer(Phonon::NoCategory, Phonon::MediaSource("sound.ogg"));
  2. mediaObject->play();
  3. delete mediaObject;

10 replies

November 7, 2011

Mohsen Mohsen
Robot Herder
731 posts

do you have “ogg” multimedia codec installed on your windows?

 Signature 

www.madagon.com

November 7, 2011

Andre Andre
Area 51 Engineer
6076 posts

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…

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

November 7, 2011

ferrazrafael ferrazrafael
Lab Rat
13 posts

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

November 7, 2011

Andre Andre
Area 51 Engineer
6076 posts

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

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

November 7, 2011

ferrazrafael ferrazrafael
Lab Rat
13 posts

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

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

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

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

November 7, 2011

Andre Andre
Area 51 Engineer
6076 posts

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.

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

November 7, 2011

ferrazrafael ferrazrafael
Lab Rat
13 posts

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

November 7, 2011

Andre Andre
Area 51 Engineer
6076 posts

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.

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

November 7, 2011

ferrazrafael ferrazrafael
Lab Rat
13 posts

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

November 8, 2011

Mohsen Mohsen
Robot Herder
731 posts

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

 Signature 

www.madagon.com

 
  ‹‹ [solved] Helper class to open a connection to an defined database      GDB cannot find a valid python installation? ››

You must log in to post a reply. Not a member yet? Register here!