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
somnathbanik
Posts: 19
Registered: ‎05-21-2012
My Device: Bold

Re: Cannot play a video using QML code

Retired
s_rashid
Posts: 127
Registered: ‎02-27-2012
My Device: Bold

Re: Cannot play a video using QML code


The code I pasted above *should* work fine. If you tested the exact code above but it still doesn't work then it might be one of the following reasons:

1) Did you link the right libraries in the .pro file?

LIBS += -lbbmultimedia -lscreen

 

* Note that the -lbbmultimedia is needed for using the Qt MediaPlayer API. -lscreen is needed for the ForeignWindowControl

 

2) Are you doing the deployment on the simulator or on the device? Unfortunately, the simulator has very limited supported on multimedia playback. This is due to the fact that the simulator doesn't have enough decoders (proprietory reasons). Feel free to open up a feature request through JIRA : https://www.blackberry.com/jira/secure/Dashboard.jspa regarding this. I have actually been trying to convince some teams for getting more codec support in the simulator; more public requests will help.

 

3) Are you getting any errors? There are two big bugs in the Qt MediaPlayer API at the moment:
* URLs with spaces don't play properly

* .m3u URLs don't play properly

 

(I have already escalated both of these issues internally - trying to get the solution in for the next SDK update(s))


Let us know if this answers your question (along with the code pasted above) & feel free to tick the thread solved if appropriate.

 

Cheers,

Rashid

Contributor
wzl0515
Posts: 27
Registered: ‎08-14-2012
My Device: bold9780

Re: Cannot play a video using QML code

hello,Rashid:

     I am using your "VideoPlaysample"  from githubn to learn how to play video. Because the SDK update from beta 2 to beta 3, the sample can not work well. I have fixed some problems such as name of ForeignWindowControl, but it still has a error about "qRegisterMetaType<bb::multimedia::MediaError::Code>("bb::multimedia::MediaError::Code");", I do not know how to deal with it. Can you help me?

 

    I still do not know if I figure that problem out that I can run the sample right. Could you please update the sample and give me the link?

Contributor
wzl0515
Posts: 27
Registered: ‎08-14-2012
My Device: bold9780

Re: Cannot play a video using QML code

Hi, when I paste your code about invokeBoundMediaPlayer to my own app, it encounter some problems.

I have add 

#include <bb/system/InvokeManager.hpp>
#include <bb/system/InvokeRequest.hpp>

in the myapp.hpp. However, when I build it, the SDK still tell me:

 

../src/CarAssistent.cpp:72:2: error: 'InvokeRequest' was not declared in this scope
../src/CarAssistent.cpp:72:2: note: suggested alternative:
d:/bbndk/target_10_0_9_386/qnx6/usr/include/bb/system/InvokeRequest.hpp:44:24: note: 'bb::system::InvokeRequest'
../src/CarAssistent.cpp:72:16: error: expected ';' before 'cardRequest'
../src/CarAssistent.cpp:73:2: error: 'cardRequest' was not declared in this scope

 

the code line is:

void CarAssistent::invokeBoundMediaPlayer(QString uri) {
InvokeRequest cardRequest;
cardRequest.setUri(uri);
cardRequest.setTarget("sys.mediaplayer.previewer");
m_invokeManager->invoke(cardRequest);
}

 

thank you very much.

 

Developer
Developer
lew
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha

Re: Cannot play a video using QML code

you probably didn't add the proper namespace, add the following line in your myapp.cpp:

 

using namespace bb::system;

 

Contributor
wzl0515
Posts: 27
Registered: ‎08-14-2012
My Device: bold9780

Re: Cannot play a video using QML code

Yes, I already add it to my myapp.cpp, but it still error like before.

Contributor
wzl0515
Posts: 27
Registered: ‎08-14-2012
My Device: bold9780

Re: Cannot play a video using QML code

Hi, your OpenSource project OpenDataSpace is too complex for me to separate the video play part. Can you give me just that part of code or tell me how to do?

Thank you very much.

Retired
s_rashid
Posts: 127
Registered: ‎02-27-2012
My Device: Bold

Re: Cannot play a video using QML code

@wzl0515,

 

1) For the errors you are getting in my VideoPlayerSample app (which hasn't been updated for Beta3), I would recommend just starting with the code I pasted in this thread already (a bare bones player), for now. A lot of things like registering the QML type, getting the absolutely path are not needed anymore. Several UI components and their attributes have also changed.

 

I will be updating the VideoPlayerSample for Beta3 and beyond, within a day or two. 

 

2) For getting rid of your compiling errors (to use the media previewer card, through the invocation framework), ensure that you have the following libraries included in the .pro file:

LIBS += -lbbsystem -lbbdata

 

Note that for using the Qt MediaPlayer, you would also need "-lbbmultimedia"; for using the ForeignWindowControl, you would need "-lscreen. Hence, in total, you might need the following:

LIBS += -lbbmultimedia -lbbsystem -lscreen -lbbdata

 

Hope this helps.

 

Cheers,

Rashid

Contributor
wzl0515
Posts: 27
Registered: ‎08-14-2012
My Device: bold9780

Re: Cannot play a video using QML code

Hello,I am using your code about invokeBoundMediaPlayer like this:

 

in myapp.cpp:

void myapp::invokeBoundMediaPlayer(QString uri) {
	InvokeRequest cardRequest;
	cardRequest.setTarget("sys.mediaplayer.previewer");
	cardRequest.setUri("file:///accounts/1000/shared/videos/VID_00000088.mp4");
	m_invokeManager->invoke(cardRequest);
}

 and I set the contestproperty in myapp.cpp:

qml->setContextProperty("myClass", this);

 

also,I define InvokeManage in myapp.hpp:

Q_INVOKABLE
        void invokeBoundMediaPlayer(QString uri) ;

private:
    QmlDocument *qml;
    NavigationPane *navigationPane;
    bb::system::InvokeManager *m_invokeManager;

 

at last, in myyapp.qml:

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);
                }

 

But it still can not work when I ues picker.open() and selecte a video file. In addition, the app will crash.

please help me,thank you very much.

Retired
s_rashid
Posts: 127
Registered: ‎02-27-2012
My Device: Bold

Re: Cannot play a video using QML code

@wzl0515

I didn't try out your code yet but just taking a quick glance at your code snippets, it seems like you are hard coding the app path to be

file:///accounts/1000/shared/videos/VID_00000088.mp4

... instead of reading it dynamically from the file picker. I am not sure if this is the issue you are facing or not but since you are trying to access the *shared* folders, did you turn on the "Shared Files" permission on the bar-descriptor.xml file?

 

Also, would you be able to share what exactly is crashing for you? What errors/logs/traces are you seeing exactly?

 

Thanks,

Rashid