From 015d09432b3f98962ec9e9f859afd49b092f1236 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sat, 21 Nov 2020 20:03:10 +0100 Subject: [PATCH] Simplify and extend media interfaces Merges the basic and extended variants into one using the optional entries. --- .../interfaces/extendedmediacontroller.json | 12 ----- .../interfaces/extendedvolumecontroller.json | 17 ------- libnymea/interfaces/interfaces.qrc | 3 -- libnymea/interfaces/mediacontroller.json | 44 ++++++++++++++++++- libnymea/interfaces/mediaplayer.json | 21 ++++++++- libnymea/interfaces/shufflerepeat.json | 16 ------- libnymea/interfaces/volumecontroller.json | 43 ++++++++---------- 7 files changed, 82 insertions(+), 74 deletions(-) delete mode 100644 libnymea/interfaces/extendedmediacontroller.json delete mode 100644 libnymea/interfaces/extendedvolumecontroller.json delete mode 100644 libnymea/interfaces/shufflerepeat.json diff --git a/libnymea/interfaces/extendedmediacontroller.json b/libnymea/interfaces/extendedmediacontroller.json deleted file mode 100644 index 1473da78..00000000 --- a/libnymea/interfaces/extendedmediacontroller.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "description": "A more advanced media controller interface, supporting fast forward and rewind", - "extends": "mediacontroller", - "actions": [ - { - "name": "fastRewind" - }, - { - "name": "fastForward" - } - ] -} diff --git a/libnymea/interfaces/extendedvolumecontroller.json b/libnymea/interfaces/extendedvolumecontroller.json deleted file mode 100644 index 59294ba9..00000000 --- a/libnymea/interfaces/extendedvolumecontroller.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "media", - "states": [ - { - "name": "mute", - "type": "bool", - "writable": true - }, - { - "name": "volume", - "type": "int", - "minValue": 0, - "maxValue": 100, - "writable": true - } - ] -} diff --git a/libnymea/interfaces/interfaces.qrc b/libnymea/interfaces/interfaces.qrc index 4e6c2c0f..c0fe0fb8 100644 --- a/libnymea/interfaces/interfaces.qrc +++ b/libnymea/interfaces/interfaces.qrc @@ -18,13 +18,10 @@ notifications.json weather.json volumecontroller.json - extendedvolumecontroller.json media.json mediacontroller.json - extendedmediacontroller.json mediametadataprovider.json mediaplayer.json - shufflerepeat.json battery.json batterylevel.json button.json diff --git a/libnymea/interfaces/mediacontroller.json b/libnymea/interfaces/mediacontroller.json index 45a2e404..d4d1d710 100644 --- a/libnymea/interfaces/mediacontroller.json +++ b/libnymea/interfaces/mediacontroller.json @@ -1,6 +1,40 @@ { - "description": "The mediacontroller interface contains basic actions to control media streams. If a device supports fast forward and rewind, use extendedmediacontroller instead.", + "description": "The mediacontroller interface contains actions to control media streams.", "extends": "media", + "states": [ + { + "name": "shuffle", + "type": "bool", + "writable": true, + "optional": true + }, + { + "name": "repeat", + "type": "QString", + "allowedValues": ["None", "One", "All"], + "writable": true, + "optional": true + }, + { + "name": "like", + "type": "bool", + "writable": true, + "optional": true + }, + { + "name": "equalizerPreset", + "type": "QString", + "allowedValues": "any", + "writable": true, + "optional": true + }, + { + "name": "nightMode", + "type": "bool", + "writable": true, + "optional": true + } + ], "actions": [ { "name": "skipBack" @@ -16,6 +50,14 @@ }, { "name": "skipNext" + }, + { + "name": "fastForward", + "optional": true + }, + { + "name": "fastRewind", + "optional": true } ] } diff --git a/libnymea/interfaces/mediaplayer.json b/libnymea/interfaces/mediaplayer.json index 3db46bf4..5dda2700 100644 --- a/libnymea/interfaces/mediaplayer.json +++ b/libnymea/interfaces/mediaplayer.json @@ -1,5 +1,5 @@ { - "description": "Media player interface. Used by devices/services which can play back media.", + "description": "Media player interface. Used by devices/services which can play back media. Even if a device only supports e.g. audio, the playerType state must still be added to the metadata. It may default to a single value and never change in this case. Players supporting duration and play time should provide those values in seconds.", "extends": "media", "states": [ { @@ -11,6 +11,25 @@ "name": "playerType", "type": "QString", "allowedValues": ["audio", "video"] + }, + { + "name": "inputSource", + "type": "QString", + "allowedValues": "any", + "writable": true, + "optional": true + }, + { + "name": "playDuration", + "type": "uint", + "unit": "Seconds", + "optional": true + }, + { + "name": "playTime", + "type": "uint", + "unit": "Seconds", + "optional": true } ] } diff --git a/libnymea/interfaces/shufflerepeat.json b/libnymea/interfaces/shufflerepeat.json deleted file mode 100644 index c96fdc63..00000000 --- a/libnymea/interfaces/shufflerepeat.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "description": "Devices/services supporting this interface can control reproduction flow. E.g. a media controller, but could also be used by light scenes or other workflows", - "states": [ - { - "name": "shuffle", - "type": "bool", - "writable": true - }, - { - "name": "repeat", - "type": "QString", - "allowedValues": ["None", "One", "All"], - "writable": true - } - ] -} diff --git a/libnymea/interfaces/volumecontroller.json b/libnymea/interfaces/volumecontroller.json index c90fb524..7f853250 100644 --- a/libnymea/interfaces/volumecontroller.json +++ b/libnymea/interfaces/volumecontroller.json @@ -1,33 +1,28 @@ { + "desciption": "A volume controller allows to control volume and mute. At the very least, increaseVolume and decreaseVolume are to be implemented for devices that don't have a way to fetch the current volume. For devices allowing to set an absolute volume value, the volume and mute states should be implemented as well.", "extends": "media", + "states": [ + { + "name": "mute", + "type": "bool", + "writable": true, + "optional": true + }, + { + "name": "volume", + "type": "int", + "minValue": "any", + "maxValue": "any", + "writable": true, + "optional": true + } + ], "actions": [ { - "name": "increaseVolume", - "params": [ - { - "name": "step", - "type": "int" - } - ] + "name": "increaseVolume" }, { - "name": "decreaseVolume", - "params": [ - { - "name": "step", - "type": "int" - } - ] - }, - { - "name": "setMute", - "params": [ - { - "name": "mute", - "type": "bool" - } - - ] + "name": "decreaseVolume" } ] }