Difference between revisions of "Audio Volume Key Event On Symbian"

From Qt Wiki
Jump to: navigation, search
(Convert ExpressionEngine section headers)
(Mark Outdated: Symbian no longer supported)
Line 1: Line 1:
{{Outdated|reason=The Symbian platform is no longer supported.}}
{{Cleanup | reason=Auto-imported from ExpressionEngine.}}
{{Cleanup | reason=Auto-imported from ExpressionEngine.}}

Latest revision as of 15:14, 19 March 2015

IMPORTANT: The content of this page is outdated. Reason: The Symbian platform is no longer supported.
If you have checked or updated this page and found the content to be suitable, please remove this notice.

This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine.
Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean.

English Български

Getting Audio Volume Key Event on Symbian Devices

In QML on Symbian devices, audio volume key events are not delivered via Keys.onVolumeDownPressed, Keys.onVolumeUpPressed, or Keys.onPressed. An appropriate solution is wrapping around S60 Remote Control API by inheriting MRemConCoreApiTargetObserver. This is an example code how to do it when building QML/C++ app. Making QML plugin should not be too far from this.

Create a new QML element to deliver the audio volume key event. The S60 Remote Control API actually can get other media key events too. Refer the link above for more detail.


#ifndef MediakeyCaptureItem_H
#define MediakeyCaptureItem_H

#include <QDeclarativeItem>

#ifdef Q_WS_S60
#include <remconcoreapitargetobserver.h> // link against RemConCoreApi.lib
#include <remconcoreapitarget.h> // and
#include <remconinterfaceselector.h> // RemConInterfaceBase.lib

class MediakeyCaptureItemPrivate;
class MediakeyCaptureItem : public QDeclarativeItem
 MediakeyCaptureItem(QDeclarativeItem *parent = 0);
 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);

 void volumeDownPressed();
 void volumeUpPressed();

 MediakeyCaptureItemPrivate *d_ptr;
private: // Friend class definitions
 friend class MediakeyCaptureItemPrivate;

#endif // Q_WS_S60
#endif // MediakeyCaptureItem_H


#include "MediaKeyCaptureItem.h"
#ifdef Q_WS_S60

// A private class to access Symbian RemCon API
class MediakeyCaptureItemPrivate : public QObject, public MRemConCoreApiTargetObserver
 MediakeyCaptureItemPrivate(MediakeyCaptureItem '''parent);
 virtual void MrccatoCommand(TRemConCoreApiOperationId aOperationId,
 TRemConCoreApiButtonAction aButtonAct);
 CRemConInterfaceSelector''' iInterfaceSelector;
 CRemConCoreApiTarget* iCoreTarget;
 MediakeyCaptureItem *d_ptr;

// Consructor
MediakeyCaptureItem::MediakeyCaptureItem(QDeclarativeItem *parent): QDeclarativeItem(parent)
 d_ptr = new MediakeyCaptureItemPrivate(this);

// The paint method
void MediakeyCaptureItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
 // This item has no visual

// Constructor
MediakeyCaptureItemPrivate::MediakeyCaptureItemPrivate(MediakeyCaptureItem *parent): d_ptr(parent)
 QT_TRAP_THROWING(iInterfaceSelector = CRemConInterfaceSelector::NewL());
 QT_TRAP_THROWING(iCoreTarget = CRemConCoreApiTarget::NewL(*iInterfaceSelector, '''this));

// Destructor
 delete iInterfaceSelector;
 delete iCoreTarget;

// Callback when media keys are pressed
void MediakeyCaptureItemPrivate::MrccatoCommand(TRemConCoreApiOperationId aOperationId,
 TRemConCoreApiButtonAction aButtonAct)
 //TRequestStatus status;
 switch( aOperationId )
 case ERemConCoreApiVolumeUp:
 emit d_ptr->volumeUpPressed();
 case ERemConCoreApiVolumeDown:
 emit d_ptr->volumeDownPressed();
#endif // Q_WS_S60

In the C++ code, register it into the declarative engine.

qmlRegisterType<MediakeyCaptureItem>("Mediakey", 1, 0, "MediakeyCapture");

Then, you need to add some lines in your .pro file to build.

 INCLUDEPATH ''= MW_LAYER_SYSTEMINCLUDE // Not sure if this is needed…
 LIBS''= -L\epoc32\release\armv5\lib -lremconcoreapi
 LIBS += -L\epoc32\release\armv5\lib -lremconinterfacebase

In QML, just listen to the signals like this

import Qt 4.7
import Mediakey 1.0


 onVolumeDownPressed: console.log('VOLUME DOWN PRESSED ')
 onVolumeUpPressed: console.log('VOLUME UP PRESSED ')


In Qt SDK 1.1 (Windows, Beta and RC) this available only for Symbian^3. But simply copy all