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
Super Contributor
JeffLemon
Posts: 440
Registered: ‎01-13-2011
My Device: Playbook
Accepted Solution

Invoking - Cards

I invoke the media player as a card. It comes on the display and when I swipe back to my app the music stops playing. Is there a way to keep the music playing and switch between my app and the card so that the user can change volume etc.

 

Thanks

--------------------------------------------------------------------------------------------------
BlackBerry Apps: Instruments | ARTPAD | Piano | Drums | Xylophone
New Contributor
grotta
Posts: 6
Registered: ‎08-23-2013
My Device: Z10

Re: Invoking - Cards

Hi, can you please share your code, i con't get pure QML code to work

 

Invocation {
                        id: mediaInvocation
                        query {
                            invokeTargetId: "sys.mediaplayer.previewer"
                            mimeType: "audio/mpeg"
                            invokeActionId: "bb.action.OPEN"
                            onQueryChanged: {
                                mediaInvocation.query.updateQuery()
                            }
                        }
                        onArmed: {
                            trigger("bb.action.OPEN");
                        }
                    }

 and on click

 

mediaInvocation.query.uri = dataModel.data(indexPath).enclosure.url
mediaInvocation.trigger("bb.action.OPEN")

 

Super Contributor
JeffLemon
Posts: 440
Registered: ‎01-13-2011
My Device: Playbook

Re: Invoking - Cards

I used C++ and a file picker/media player. The user selects a file and on selection the media player is invoked.

 

//MEDIA PLAYER
	mp = new MediaPlayer();
	mp->isSeekable();

	//FILE PICKER
	filePicker = new FilePicker();
	filePicker->setType(FileType::Music);
	filePicker->setTitle("Select Music");
	filePicker->setMode(FilePickerMode::Picker);
	QObject::connect(filePicker, SIGNAL(fileSelected(const QStringList&)),this,SLOT(onFileSelected(const QStringList&)));

void ControllerDrumKit::onFileSelected(QStringList list)
{

       mp->setSourceUrl(QString(list[0]));
	mp->play();

}

 Hope this helps.

--------------------------------------------------------------------------------------------------
BlackBerry Apps: Instruments | ARTPAD | Piano | Drums | Xylophone
Retired
PBernhardt
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30

Re: Invoking - Cards

To answer the original question, incase anyone turns up here later: No, the playback is being handled by the card. Once the card is gone, the playback has to stop. If you want it to keep playing, you have have to play the file yourself inside your app, which is what I assume Jeff has done.

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker