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: 614
Registered: ‎10-17-2010
My Device: (BlackBerry Z10)-> Q10/Passport Dual Use

onPlaybackCompleted signal issue MediaPlayer



I am using the the dictaphone sample. https://github.com/blackberry/Cascades-Samples/tree/master/dictaphone


The MediaPlayer  is an attachedObject.


attachedObjects: [
MediaPlayer {
    id: player


The code to tap a sound and play it is the following:


 player.sourceUrl = ""
// Set the currently selected track as player source URL
 player.sourceUrl = listView.dataModel.data(listView.selected()).url
// Start playback

I tap the sound and get the following output in the debug console


START 1 MediaPlayerPrivate::onBufferStatusChanged 
MediaPlayerPrivate::onBufferStatusChanged: emit bufferStatusChanged()
MediaPlayerPrivate::onBufferStatusChanged:   bufferStatus=Idle
=> END 1 ( 0 ms): 
=> END 1 ( 3 ms): 
=> END 1 ( 4 ms): 
START 1 MmrContextNotifier::onReadyRead 
MmrContextNotifier::onReadyRead: QMap(("@state", PpsAttribute(Object, QFlags() ,  QMap(("error", PpsAttribute(String, QFlags() ,  "0" ) ) ( "error_pos" ,  PpsAttribute( String,  QFlags() ,  "1:1924" ) ) ( "speed" ,  PpsAttribute( String,  QFlags() ,  "1000" ) ) ( "state" ,  PpsAttribute( String,  QFlags() ,  "stopped" ) ) )  ) ) )  
START 1 MmrContextNotifier::onPpsStateChanged 
MmrContextNotifier::onPpsStateChanged: emit playbackCompleted()
START 1 MediaPlayerPrivate::onMmrPlaybackCompleted 
START 1 MediaPlayerPrivate::setMediaState 
MediaPlayerPrivate::setMediaState: emit mediaStateChanged()
MediaPlayerPrivate::setMediaState:   mediaState=Stopped
=> END 1 ( 0 ms): 
MediaPlayerPrivate::onMmrPlaybackCompleted: emit playbackCompleted()
=> END 1 ( 0 ms): 
=> END 1 ( 1 ms): 
=> END 1 ( 3 ms): 


I need to connect eht playbackCompleted() signal from the MediaPlayer to code in my qml page.


I tried adding


    // do something

 to the MediaPlayer attached object with no luck. 


I am thinking that there should be a way to connect the playbackCompleted signal to using CPP. Need assistance.



Also. How do I get the length of the audio clip in qml/cpp based on the sample code?



Posts: 614
Registered: ‎10-17-2010
My Device: (BlackBerry Z10)-> Q10/Passport Dual Use

Re: onPlaybackCompleted signal issue MediaPlayer

bump up

Posts: 1,178
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: onPlaybackCompleted signal issue MediaPlayer

A litte soon for a bump...


Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: onPlaybackCompleted signal issue MediaPlayer

Generally if a signal fires in C++ it will fire in QML so changing it to C++ won't make a difference, there are always a small number of bugs between C++ and QML (look at invocation problems for an example) but I haven't heard of any for MediaPlayer.


Check your code or post the whole thing here to be looked at.


As long as the media format you are playing supports it you should be able to get the length from metaData().




Alternatively from the durationChanged() signal.

If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Posts: 33
Registered: ‎12-05-2013
My Device: Z10
My Carrier: 123456789

Re: onPlaybackCompleted signal issue MediaPlayer

Try onMediaStateChanged() and detect if the state is MediaState.Stopped