Sound and the using of the Resource system
-
This post was split off from "this discussion":http://developer.qt.nokia.com/forums/viewthread/4453/ on certification; Andre
A huge desire to develop Qt and it's usages further!
It has all of potential to grow.
For example:
a) When they add support QSound class can read .wav files embedded into executable ( Qt Resources)?
b) How can I put any .txt file into Resources ( embbed ) and read it via QFile?
Pavel -
Any file that uses Qt's file access mechanisms can be read from the resource system. That certainly includes text files that you want to access via QFile. What don't you understand from the documentation on the Qt Resource System?
-
Yes, just use qt-creator's qrc editor or edit the file by hand to add in any file that you like.
In your app just pass in a path prefixed with a ":" to access the file from the compiled in resources. ie:
@
QFile file( ":/path/to/my/sound.wav" );
if ( !file.open( QIODevice::ReadOnly ) )
return;// Play the file...
@ -
But please don't use QSound! :-)
-
Hey!
I specially ask when QSound() will open wav files from resources?
That is the question when QSound class will work with .wav files from resource system. -
[quote author="Pavel Mazniker" date="1300194760"]Hey!
I specially ask when QSound() will open wav files from resources?
That is the question when QSound class will work with .wav files from resource system.[/quote]
Probably the answer is "never". It is documented that QSound does not support loading from resources. QSound is not marked as such, but AFAIK it is basically deprecated. Use QtMultimedia or Phonon instead. -
As Andre says, QSound does not support playing from resources. So either use QtMultimedia or -Phone- Phonon. Or submit a merge request in gitorious to make QSound support resources.
-
OK.