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
Contributor
Posts: 27
Registered: ‎08-14-2012
My Device: bold9780
My Carrier: T-MOBILE

Problem about Invocation card Media Player

Hello all, cause the sdk up to the gold version, I found the Invocation about Media Player have some thing change. So my code is going wrong when call the card to play vedio.

my code is like this:

void Myapp::invokeBoundMediaPlayer(QString uri) {
	InvokeRequest cardRequest;
	cardRequest.setTarget("sys.mediaplayer.previewer");
	cardRequest.setUri(uri);
	InvokeManager invokeManager;
	invokeManager.invoke(cardRequest);
}

 and in qml file:

    attachedObjects: [
            FilePicker {
                id: picker
                property string selectedFile
                title: qsTr("File Picker")
                mode: pickerMode.selectedValue
                type: pickerType.selectedValue
                viewMode: pickerViewMode.selectedValue
                sortBy: pickerSortBy.selectedValue
                sortOrder: pickerSortOrder.selectedValue
                onFileSelected: {
                    selectedFile = selectedFiles[0]
                    myClass.invokeBoundMediaPlayer(selectedFile);
                }
            }
]

 

so when I run my application, It said "Cannot assign [undefined] to QString".

I need your help, thank you very much.

Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: Problem about Invocation card Media Player

yep - something changed with the pathes

check if your URI starts with "/" and if, then

prefix URI with "file://"

 

and I promise it will work.

 

I run into the same problem

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Contributor
Posts: 27
Registered: ‎08-14-2012
My Device: bold9780
My Carrier: T-MOBILE

Re: Problem about Invocation card Media Player

Thank you very much. However, you can see the code I have posted that the uri is get by picker automatically. So how can I change the uri to file://?

Can you show me some codes or just fix it on the code I have posted?

 

It is important for me, thank you again.

Contributor
Posts: 27
Registered: ‎08-14-2012
My Device: bold9780
My Carrier: T-MOBILE

Re: Problem about Invocation card Media Player

Should I do like this?

cardRequest.setUri("file:/"+uri);

 

 

Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: Problem about Invocation card Media Player

yes - if the only source of URI is from FilePicker

iuf there are different sources you can test if the uri starts with "/" and then prefix with file://

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: Problem about Invocation card Media Player

this should work:

// invoke MediaPlayer
void OpenDataSpace::invokeBoundMediaPlayer(const QString& uri) {
	qDebug() << "invoke bound mediaplayer" << uri;
	InvokeRequest cardRequest;
	// MediaPlayer needs file:// or http:// etc as prefix
	// FilePicker uses /account....... etc
	if (uri.startsWith('/')) {
		cardRequest.setUri("file://" + uri);
	} else {
		cardRequest.setUri(uri);
	}
	cardRequest.setTarget("sys.mediaplayer.previewer");
	mInvokeManager->invoke(cardRequest);
}

 

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Contributor
Posts: 27
Registered: ‎08-14-2012
My Device: bold9780
My Carrier: T-MOBILE

Re: Problem about Invocation card Media Player

I do like this but it still doesn't work:

// invoke MediaPlayer
void CarAssistent::invokeBoundMediaPlayer(QString uri) {
	InvokeRequest cardRequest;
	cardRequest.setTarget("sys.mediaplayer.previewer");
	cardRequest.setUri("file://"+uri);
	InvokeManager invokeManager;
	invokeManager.invoke(cardRequest);
}

 is there some thing wrong?

Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: Problem about Invocation card Media Player

only difference seems to be devlaration of InvokeManager ?

 

bb::system::InvokeManager *mInvokeManager;

 

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Highlighted
Contributor
Posts: 27
Registered: ‎08-14-2012
My Device: bold9780
My Carrier: T-MOBILE

Re: Problem about Invocation card Media Player

I do like this:

// invoke MediaPlayer
void CarAssistent::invokeBoundMediaPlayer(QString uri) {
	qDebug() << "invoke bound mediaplayer" << uri;
	InvokeRequest cardRequest;
	//cardRequest.setUri("file://"+uri);

	if (uri.startsWith('/')) {
			cardRequest.setUri("file://" + uri);
		} else {
			cardRequest.setUri(uri);
		}
	cardRequest.setTarget("sys.mediaplayer.previewer");
	InvokeManager invokeManager;
	invokeManager.invoke(cardRequest);
}

 and it shows that:

Received childCardDone message:  "save" "[{"uri":"file:///accounts/1000/shared/camera/VID_00000006.mp4"}]" 

Received a message from the viewer: "[{"uri":"file:///accounts/1000/shared/camera/VID_00000006.mp4"}]" 

messageFromChildCard():  "" 

file:///apps/com.example.Myapp.testDev_r_Assistente806a0c6/native/assets//main.qml:120: Error: Cannot assign [undefined] to QString

 please help me, thank you!

 

Contributor
Posts: 27
Registered: ‎08-14-2012
My Device: bold9780
My Carrier: T-MOBILE

Re: Problem about Invocation card Media Player

where should i add this line of code?