Zotop
25th November 2010, 23:47
Hi everyone,
I've been travelling between posts and documentation but haven't found a solution for the following problem.
I'm using Netbeans under Ubuntu and Qt 4.7.1.
I'm doing a small alarm clock application and having some problems with the sound.
When I compile and run from Netbeans, the sound works, but not when I run the executable file outside Netbeans.
I had the same problem with some images but it got fixed by using a resource file.
Here is my resource file :
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>icons/up_arrow.png</file>
<file>icons/down_arrow.png</file>
<file>sounds/alarm_clock.wav</file>
</qresource>
</RCC>
And here is how I play a sound using Phonon :
Phonon::MediaObject *music;
music = Phonon::createPlayer(Phonon::MusicCategory,Phonon: :MediaSource("sounds/alarm_clock.wav"));
music->play();
Any help would be appreciated.
Added after 10 minutes:
Ok solution found :)
For those who might face this problem, here it goes;
Adding ":/" solves the problem :
music = Phonon::createPlayer(Phonon::MusicCategory,Phonon: :MediaSource(":/sounds/alarm_clock.wav"));
Should have read further... Sorry. :D
I've been travelling between posts and documentation but haven't found a solution for the following problem.
I'm using Netbeans under Ubuntu and Qt 4.7.1.
I'm doing a small alarm clock application and having some problems with the sound.
When I compile and run from Netbeans, the sound works, but not when I run the executable file outside Netbeans.
I had the same problem with some images but it got fixed by using a resource file.
Here is my resource file :
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>icons/up_arrow.png</file>
<file>icons/down_arrow.png</file>
<file>sounds/alarm_clock.wav</file>
</qresource>
</RCC>
And here is how I play a sound using Phonon :
Phonon::MediaObject *music;
music = Phonon::createPlayer(Phonon::MusicCategory,Phonon: :MediaSource("sounds/alarm_clock.wav"));
music->play();
Any help would be appreciated.
Added after 10 minutes:
Ok solution found :)
For those who might face this problem, here it goes;
Adding ":/" solves the problem :
music = Phonon::createPlayer(Phonon::MusicCategory,Phonon: :MediaSource(":/sounds/alarm_clock.wav"));
Should have read further... Sorry. :D