Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Contributor
jaganmca09
Posts: 9
Registered: ‎03-21-2012
My Device: Blackberry Bold - 9700
My Carrier: Airtel

BB10 Cascades - MediaPlayer initialization

Hi ,

 

Ihave include header file

 

#include <bb/multimedia/MediaPlayer>

 

and namespace

 

using namespace bb::multimedia;

 

then I tried to initialize MediaPlayer as given in this API link

https://developer.blackberry.com/cascades/reference/bb__multimedia__mediaplayer.html

 

MediaPlayer mp(this);

 

The I tried to build the application. It is giving error

 

undefined reference to `bb::multimedia::MediaPlayer::MediaPlayer(QObject*).

 

Then I tried as

MediaPlayer mp(QObject *parent=0);

 

in this time it didn't give error but after I tried to add  source url

 

mp.setSourceUrl(QUrl("asset:///media.mp3"));

 

then I tried to build aging now it is giving error

 

request for member 'setSourceUrl' in 'mp', which is of non-class type 'bb::multimedia::MediaPlayer(QObject)'

 

Do I need to follow any ohter steps to use MediaPlayer?

 

Thanks,

Jagan

Please use plain text.
Developer
noahhuang
Posts: 100
Registered: ‎10-01-2012
My Device: BB10 Dev Alpha
My Carrier: Roger

Re: BB10 Cascades - MediaPlayer initialization

[ Edited ]

using namespace bb::multimedia;

 

MediaPlayer m_Player(this);
m_Player.setSourceUrl(QString("asset:///sounds/").arg("test.wav"));
m_Player.prepare();
m_Player.play();

 

but the audio file attached has a problem on beta 4

Please use plain text.
Developer
kylefowler
Posts: 526
Registered: ‎05-17-2009
My Device: 9900
My Carrier: ATT

Re: BB10 Cascades - MediaPlayer initialization

That source url line wont do anything. It will just pass "asset:///sounds/" into the setsourceurl method. If youre going to do .arg(). It needs to be like this

m_Player.setSourceUrl(QString("asset:///sounds/%1").arg("test.wav"));
Like all of my posts
Please use plain text.
Developer
nemoryoliver
Posts: 97
Registered: ‎11-13-2012
My Device: BB10 Simulator
My Carrier: Globe Telecom

Re: BB10 Cascades - MediaPlayer initialization

I have the same problem. How to fix this please?

Please use plain text.