Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED] Play sound using qml in resource on Symbian
I'm getting crazy with that!!!
I've tried to use SoundEffect or Audio qml tag within qml located in resource (also the audio file was in a resource file).
I've tried in C++ using a real audio file (copying it with DEPLOYMENTFOLDERS) and QMediaPlayer: the file path was correct but I have not heard anything!
I'm in process of create an app fpr both symbian and meego, so I want to use the same code (on MeeGo, using qml and sound files in the resource works just with SoundEffect tag; the same doesn't work on symbian).
How can I achieve that??
I've tested it on a nokia x7 and c7
I am also using the QML SoundEffect and Audio element from QtMultimediaKit 1.1 for both Symbian and Meego for a game. From my experience, they both work with the same code. However, Meego has some troubles with multiple simultaneous sound effects while a background music (Audio) is playing.
Maybe your issues have something to do with the audio sampling rate or frequency? The background music I'm using for the Audio element has a frequency of 48kHz and 128kbit quantization, the file format is mp3. An example for a working sound effect is a wav file with 44.1kHz, 1 channel and 16 bits per sample.
These audio files are loaded with the DEPLOYMENTFOLDERS approach, so not from the resource file.
I hope that helps?
Hi, thank you for your help...
I have some experience on symbian and meego handling sounds; I've done a game using sounds as you said, but in the case of qml within resource, that works only on meego! i don't know why.
If the qml isn't in resource file, the DEPLOYEMNTFOLDERS works very well!
As I told, i've tried to copy sounds in to device and open that (always in qml within resource) without success!
Why the same tecnique doesn't work for both?!
I'm afraid I dont know why playing from resources isnt working on Symbian.. Is just using the deploymentfolders approach not an option for you?
So as a recap:
- sounds & qml as deploymentfolders -> works on Symbian & meego
- qml in resource, sound not in resource but with deploymentfolders -> does NOT work on symbian, but works on meego
- what about both, the qml file and sound file in resource?
It's very difficult to recap;
In my experience, on Symbian I've always used qml and sounds as normal files and not in resources; on the other side, on Meego I've always used qml and sounds as resources;
i'm not crazy if I did that...I suppose that on meego works both method!
1- Sounds & qml as deploymentfolders: valid for Symbian & Meego
2- Qml in resources and sounds on deploymentfolders doesn't work for both (on Symbian sure!)
3- Actually, qmls & sounds in resources work only for Meego
I think that is because when you use qml/js in resource and use relative path for sounds, it translate absolute path as "qrc:/bla/bla.wav"
Yes you are right, based on the setMainQmlFile() call (in case you are using the QmlApplicationViewer), the baseUrl of the QDeclarativeEngine is set. So if you call setMainQmlFile(":/main.qml"), every qml file, image or sound file is prepended with ":/".
So the easiest approach to me seems, to just use deploymentfolders on both platforms. If that is not an option, you could use qml & sounds in the resources for Meego, and from deploymentfolders for Symbian. So you could decide at runtime which one to use like this:
// on symbian use the copied files with DEPLOYMENTFOLDERS
// on meego use the resources
// for desktop, whatever you prefer
Sure...nice, maybe it could be a good idea!!
[quote author="feldifux" date="1342621086"]
So you could decide at runtime which one to use
I've used this way and even is a huge solution (resources and files) it works very well on both!!