01-04-2013 09:42 PM
Hi everybody,
Can you confirm that there are some issues with the MediaPlayer on Gold SDK?
The MediaPlayer works well on qml as an attached object but not in C++
I've tried to implement MediaPlayer like this
MediaPlayer mp(this);
mp.setSourceUrl(QUrl("asset:///sounds/test.mp3"));
mp.play();
The problem is that there was no sound
I also tried to play local file:
MediaPlayer mp(this);
mp.setSourceUrl(QUrl("file:///accounts/1000/shared /music/test.mp3"));
mp.play();
Even though
MediaPlayer mp(this);
mp.setSourceUrl("file:///accounts/1000/shared/musi c/test.mp3");
mp.play();
I've allowed access_shared and there was no sound also!!! ![]()
So, can you guys got the same problems?
01-05-2013 03:33 AM
works fine for me in OpenDataSpace with sound
.mp3 .ogg .wav .m4a
void OpenDataSpace::invokeBoundMediaPlayer(const QString& uri) {
qDebug() << "invoke bound mediaplayer" << uri;
InvokeRequest cardRequest;
if (uri.startsWith('/')) {
cardRequest.setUri("file://" + uri);
} else {
cardRequest.setUri(uri);
}
cardRequest.setTarget("sys.mediaplayer.previewer") ;
mInvokeManager->invoke(cardRequest);
}
01-05-2013 05:37 AM
Thanks @ekke, but I dont't want to Invoke any cards, just play the sound in the background ![]()
01-05-2013 06:22 AM
longmilk wrote:
Thanks @ekke, but I dont't want to Invoke any cards, just play the sound in the background
aaah - understand. have not done this yet
01-07-2013 11:51 PM
I'm encountering the same thing, but only in Release build - I get sound in Debug builds ok.
Also, even in debug builds I can't seem to get setSourceUrl to work with a file:// type, and according to docs it's also supposed to work with just "/sounds/test.mp3" and then assume asset:// but it doesn't.
Hunting for a solution...
02-03-2013 10:27 AM
02-03-2013 12:59 PM
I haven't had a chance to go back and test after the last SDK update, I had intended to create a simple repro case for it... but my "solution" to get sound working was to switch my app to use the OpenAL interfaces. Doesn't play all the same formats, though.
02-03-2013 03:01 PM - edited 02-03-2013 03:05 PM
This works, ignore the example code:
MediaPlayer* mp = new MediaPlayer();
mp->setSourceUrl(QString("file:///accounts/1000/sh ared/music/2.mp3"));
mp->play();
02-03-2013 03:47 PM
Ah, but that example plays a file that is included in the 'shared' file area. What if the file is only in the private 'assets' area?
02-03-2013 05:06 PM
Use this for any sound that's included in your app:
mp->setSourceUrl(QString(QDir::currentPath() +"/app/native/assets/sounds/2.mp3"));