12-26-2012 10:17 AM
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.
12-26-2012 11:11 AM
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
12-26-2012 11:23 PM
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.
12-26-2012 11:25 PM
Should I do like this?
cardRequest.setUri("file:/"+uri);
12-27-2012 02:11 AM
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://
12-27-2012 04:47 AM
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);
}
12-27-2012 05:24 AM
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?
12-27-2012 05:31 AM
only difference seems to be devlaration of InvokeManager ?
bb::system::InvokeManager *mInvokeManager;
12-27-2012 05:34 AM
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_Assistent e806a0c6/native/assets//main.qml:120: Error: Cannot assign [undefined] to QStringplease help me, thank you!
12-27-2012 05:36 AM