10-31-2012 04:14 PM
If I use the following
musicPlayer = new bb::multimedia::MediaPlayer(this); MediaError::Type anError = musicPlayer->setSourceUrl(QUrl("asset:///sounds/mu
sic/sample.mp3")); if (anError == bb::multimedia::MediaError::None) musicPlayer->play();
There is no sound coming out. I linked all the libraries.
From the documentation:
Permissions: Applications that call into this class will require the play_audio, access_shared permission.
if I add play_audio to the bar-descriptor - there is an error that play_audio is not recognized.
Any ideas why there is no sound coming out?
Solved! Go to Solution.
10-31-2012 05:10 PM
1) Currently, there are some limitations in the MediaPlayer API. One of the limitations is the fact that it requires absolute path of the media file that it is trying to play. You can replace the "setSourceUrl" invocation in the following manner to make it work:
MediaError::Type anError = musicPlayer->setSourceUrl(QDir::currentPath() + "/app/native/assets/sounds/sample.mp3");
We are aware that this particular API limitation is a big annoyance and we have already forwarded the requests to the the development team.
2) With respect to the permissions required, you shouldn't need either one of those permissions if you are just playing a media file packaged within the app. The documentation is outdated. We have already alerted the documentation teams to fix this as soon as possible.
The "access_shared" permission would be required if you are trying to play a media file from the "shared" directories. For that, the "setSourceUrl" invocation would be something like this:
MediaError::Type anError = musicPlayer->setSourceUrl("/accounts/1000/shared/m
Hope this helps and let us know if you have any further questions or comment.
11-01-2012 09:46 AM
Unfortunately - still no sound. No errors reported either and I must have checked the path 10 times at least to make sure I have it right.
I tried to find how to control the volume since I thought maybe it's just the gain that's set too low, but I could not find how to control the volume - is there a way to do that?
I linked the following
Is that enough for MediaPlayer to work or do I need to link some other libraries which would not prevent me to compile but might result in no sound?
11-01-2012 01:49 PM
That library should be enough to make it work from Beta 3 and onwards (there were more limitations in Beta 2).
For your "no sound" problem, I am guessing you might be missing one of the things below (can you double check the following things...)
Hope this helps and let us know how it goes.
11-01-2012 02:38 PM
Those are for OpenAL sound management and those work as expected. I can hear the sound if I use .wav files. The issue here is to play .mp3 files using the MediaPlayer.
I'll try to debug some more using the outlined steps and report back.
11-01-2012 02:53 PM
I verified that the absolute path is ok, but in point #5 I found a problem.
I opened the browser (I only have the simulator at this point unfortunately) and tried to play an MP3 file and a Wav file.
the Wav file plays fine, the mp3 file prduces an error
"There was an error decoding this media."
"The media format may not be supported."
So the simulator device cannot play mp3 files at all it seems.