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
Regular Contributor
andreyavram
Posts: 76
Registered: ‎06-02-2012
My Device: Playbook, BB10
My Carrier: Orange

Re: MediaKey

I managed to make it compile succesfully using your latest instructions about slots. However I think that creating slots, hence having to subclass the QObject interferes with the something else because altough the compiles with the hltm5 code succesfull and I can see it's methods from the console, when I call it I get a javascript alert saying it can't find "usr/lib/webplatform/plugins/jnext/libTemplate.so" Library ... like it said when I forgot to add some libraries to the build path.(I already have bbmultimedia added).

 

This is the template_ndk.cpp

....
#include <bb/multimedia/MediaKey> #include <bb/multimedia/MediaKeyWatcher> #include <bb/multimedia/MediaKeyNotification> #include <QObject> namespace webworks { bb::multimedia::MediaKeyWatcher* keyWatcher = new bb::multimedia::MediaKeyWatcher(bb::multimedia::MediaKey::VolumeUp); TemplateNDK::TemplateNDK(TemplateJS *parent) { bps_initialize(); bool success = QObject::connect(keyWatcher, SIGNAL(shortPress(bb::multimedia::MediaKey::Type)), this, SLOT(signal_test())); } TemplateNDK::~TemplateNDK() {} std::string TemplateNDK::templateTestString() { return "Template Test Function"; } void signal_test(){ //templateTestString(); } ... }

 and here is the template_ndk.hpp

....
#include <string>
#include <pthread.h>
#include <QObject>

class TemplateJS;

namespace webworks {

class TemplateNDK : public QObject {
	Q_OBJECT
public:
	explicit TemplateNDK(TemplateJS *parent = NULL);
	virtual ~TemplateNDK();

	// The extension methods are defined here
	std::string templateTestString();
	std::string templateTestString(const std::string& inputString);
	std::string getTemplateProperty();
	void setTemplateProperty(const std::string& inputString);
	void templateTestAsync();
	void templateTestAsyncJSON();
	void templateCallback();
	void templateCallbackJSON();
	void templateCallbackJSONio(const std::string& inputString);

public slots:
     void signal_test();

.....

 

 I have a feeling that what I'm trying to achieve, will only work using true native C++, not QT stuff...unfortunately.

Please use plain text.
Administrator
MSohm
Posts: 14,528
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: MediaKey

A few things to check.

 

1) Make sure you are using the correct libTemplate.so (e.g. using the /device version instead of /simulator)
2) Make sure you have a <feature> element defined in config.xml for this extension.
3) Make sure you have correctly filled in the corresponding manifest.json, index.js and client.js files.


This Lab from BlackBerry Jam Europe on this subject may help:
https://github.com/blackberry/Presentations/tree/master/2013-BlackBerryJam-Europe/JAM335

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Regular Contributor
andreyavram
Posts: 76
Registered: ‎06-02-2012
My Device: Playbook, BB10
My Carrier: Orange

Re: MediaKey

Hi MSohm,

Thanks for your answers.

 

1) and 2) are definitely not to blame. 

 

About 3) I'm not sure. It's not clear for me what/where should I add in those files, right now I'm using the ones from the standard template https://github.com/blackberry/WebWorks-Community-

APIs/tree/master/BB10/Template/ext/community.templateExt

 

Considering that I defined a new method in the template_ndk.cpp ( void signal_test() ) so I can declare it as a slot on template_ndk.hpp (notice that I also sub-classed TemplateNDK from QObject), what should I add/modify in the manifest.json, index.js and client.js files? 

The rest of the code, not posted above, is the standard template extension. 

 

My final intention, is to be able to receive the midle button  mediakey click event in my JS code and perhaps the longPress event on both Vol+ and Vol- keys. 

 

Thanks!

Please use plain text.