MediaKeyWatcher
#include <bb/multimedia/MediaKeyWatcher>
To link against this class, add the following line to your .pro file: LIBS += -lbbmultimedia
Represents a hardware media key and provides notification.
If two MediaKeyWatcher objects reference the same MediaKey then the last one to connect the signal will receive the notification until all the slots are disconnected from that signal. A short press is defined as being less than 650ms in duration and a long press is 650ms or greater in duration.
There are two different notification types for this media key watcher. MediaKeyNotification.Clicked is the default and results in the respective press signals to be called when the hardware media key is released. MediaKeyNotification.Threshold causes press to be signaled once the earliest connected signal threshold is reached (0ms for shortPress and 650ms for longPress). If both shortPress and longPress are connected the shortPress signal will only be emitted.
When all slots are disconnected from a signal, notification is returned to the last MediaKeyWatcher object that is connected to the signal of the same media key. Otherwise the default action from now playing is triggered.
C++ example:
MediaKeyWatcher keyWatcher(MediaKey::VolumeUp); ... QObject::connect(&keyWatcher, SIGNAL(longPress(bb::multimedia::MediaKey::Type)), this, SLOT(onLongPress()); QObject::connect(&keyWatcher, SIGNAL(shortPress(bb::multimedia::MediaKey::Type)), this, SLOT(onShortPress());
QML example:
import bb.multimedia 1.0
...
attachedObjects: [
MediaKeyWatcher {
id: keyWatcher
key: MediaKey.VolumeUp
onLongPress: {
// do something
}
onShortPress: {
// do something
}
}
]
BlackBerry 10.0.0
Properties Index
Public Functions Index
| MediaKeyWatcher (MediaKey::Type key, QObject *parent=0) | |
| MediaKeyWatcher (QObject *parent=0) | |
| virtual | ~MediaKeyWatcher () |
| MediaKey::Type | key () const |
| MediaKeyNotification::Type | notification () const |
Public Slots Index
| void | setNotification (bb::multimedia::MediaKeyNotification::Type notification) |
Signals Index
| void | longPress (bb::multimedia::MediaKey::Type key) |
| void | notificationChanged (bb::multimedia::MediaKeyNotification::Type notification) |
| void | shortPress (bb::multimedia::MediaKey::Type key) |
Properties
bb::multimedia::MediaKeyNotification::Type
Represents any of the media button types.
BlackBerry 10.1.0
Public Functions
Constructs a MediaKey object.
Create and associates a MediaKey with a specific media button.
| Parameters | |
|---|---|
| key |
The MediaKey::Type to watch. |
| parent |
An optional parameter to specify the parent of this QObject. |
BlackBerry 10.0.0
Constructs a MediaKey object.
Create and associates a MediaKey with MediaKey::None.
| Parameters | |
|---|---|
| parent |
An optional parameter to specify the parent of this QObject. |
BlackBerry 10.0.0
virtual
Destructor.
BlackBerry 10.0.0
MediaKey::Type
Provides the MediaKey associated with this watcher.
the media type providing notifications.
BlackBerry 10.0.0
MediaKeyNotification::Type
Provides the MediaKeyNotification associated with this key watcher.
the media type notification type.
BlackBerry 10.1.0
Public Slots
void
Used to set the media key notification type.
When the notification type MediaKeyNotification::Clicked is set the media key signals will not fire until the hardware key has been released. For MediaKeyWatcher::Threshold the media key signal will fire as soon as the press threshold has been reached for the given length. In this case the press signal will only occur for the earliest connected signal.
| Parameters | |
|---|---|
| notification |
The media key notification type to use. |
BlackBerry 10.1.0
Signals
void
Signal emitted for a media key long press.
This signal is emitted when the associated media button has been pressed for more than 700ms.
BlackBerry 10.0.0
void
Signal emitted when the notification type has changed.
BlackBerry 10.1.0
void
Signal emitted for a media key short press.
This signal is emitted when the associated media button is pressed for less than 350ms.
BlackBerry 10.1.0