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

Posts: 325
Registered: ‎10-01-2012
My Device: Dev Alpha C, Playbook 32 GB
My Carrier: BleskMobil

Using Slider together with MediaPlayer



I'm trying to use Slider in connection with MediaPlayer for this two purposes:


1) to show progress of played track

2) to allows user to seek on played track


Naive solution is to bind Player position to Slider value.


Unfortunatelly I'm not able to distinguish whether value was set by binding or by user. 


My current conclusion is to implement my own Slider that will not behave in this way (most likely it will be inspired by https://developer.blackberry.com/cascades/documentation/dev/integrating_cpp_qml/custom_control_tutor...


Any idea how to do it without creating my own slider implementation?




-- My Blackberry 10 app at http://blackberry.hubalek.net
-- My Android apps at http://android.hubalek.net
Posts: 76
Registered: ‎02-08-2013
My Device: z10
My Carrier: rogers

Re: Using Slider together with MediaPlayer

Hi There,


I found your post because I had the same problem, the link you provided led me to the solution though. It's not a perfect solution but it seems to work well enough to permit the slider to be updated by the media player AND allow the user to seek. It's basically a question of making a distinction between user instigated value changes versus media player instigated changes. The only way to do this is to key on to the touch signal the Slider widget inherits.


The media player's positionChanged signal is responsible for changing the slider value:

connect(&mediaPlayer, SIGNAL(positionChanged(unsigned int)), this, SLOT(onMediaPlayerPositionChanged(unsigned int)));

void app::onMediaPlayerPositionChanged(unsigned int position)

 Which then triggers the slider's valueChanged signal, defined like this:

connect(&playSlider, SIGNAL(valueChanged(float)), this, SLOT(onPlaySliderValueChanged(float)));

void app::onPlaySliderValueChanged(float value)
	if (sliderUpdatedByTouch == true) {
		sliderUpdatedByTouch = false;

 The solution is already given away, it's a matter to determining if the slider value was changed by touch event, which is detected in the following manner:

connect(&playSlider, SIGNAL(touch(bb::cascades::TouchEvent*)), this, SLOT(onPlaySliderTouch(bb::cascades::TouchEvent*)));

void bepod::onPlaySliderTouch(bb::cascades::TouchEvent* touchEvent)
	if (touchEvent->isUp())
		sliderUpdatedByTouch = true;

 This seems to do the job so far.


Hope this helps.