From 0bf77218154a878cf87bcc60a7efd9674d6ddc2b Mon Sep 17 00:00:00 2001 From: mschlgl Date: Tue, 1 Jun 2021 19:41:34 +0200 Subject: [PATCH] added smd202 --- admin/lib/device_mapping.json | 12 +- admin/lib/objects_templates.json | 61 +++++++++++ main.js | 183 ++++++++++++++++++++++++++++++- 3 files changed, 253 insertions(+), 3 deletions(-) diff --git a/admin/lib/device_mapping.json b/admin/lib/device_mapping.json index 08e7b8c..b40a27e 100644 --- a/admin/lib/device_mapping.json +++ b/admin/lib/device_mapping.json @@ -30,8 +30,16 @@ "name" : "SMD 202", "short" : "smd202", "objects" : [ - "common" - ] + "common", + "smd202" + ], + "ply" : { + "players": { + "name" : "Video Player", + "short" : "P", + "amount" : 1 + } + } }, "SME211" : { "name" : "SME 211", diff --git a/admin/lib/objects_templates.json b/admin/lib/objects_templates.json index 816f24a..5999b02 100644 --- a/admin/lib/objects_templates.json +++ b/admin/lib/objects_templates.json @@ -1188,5 +1188,66 @@ "native": {} } ] + }, + "smd202" :{ + "player": { + "_id": "0", + "type": "folder", + "common": { + "name": "Player" + }, + "native": {} + }, + "players": [ + { + "_id": "common", + "type": "channel", + "common": { + "role": "player.channel", + "name": "Common player parameters" + }, + "native": {} + }, + { + "_id": "common.playmode", + "type": "state", + "common": { + "role" : "value", + "name" : "if true the player is playing", + "type" : "number", + "states" : "0:stop; 1:play; 2:pause", + "read" : true, + "write" : true, + "def" : false + }, + "native" : {} + }, + { + "_id": "common.loopmode", + "type": "state", + "common": { + "role" : "switch", + "name" : "if true the player is repeating", + "type" : "boolean", + "read" : true, + "write" : true, + "def" : false + }, + "native" : {} + }, + { + "_id" : "common.filepath", + "type" : "state", + "common" : { + "role" : "value", + "name" : "filepath of currently loaded player file", + "type" : "string", + "read" : true, + "write" : true, + "def" : " " + }, + "native" :{} + } + ] } } diff --git a/main.js b/main.js index 7a3de04..817375a 100644 --- a/main.js +++ b/main.js @@ -418,6 +418,27 @@ class Extron extends utils.Adapter { self.log.silly(`Extron got video mute for output "${ext1}" value "${ext2}"`); self.setState(`connections.${ext1}.mute`, Number(ext2), true); break; + + case 'PLYRS' : // received video playing + self.log.silly(`Extron got video playing for output "${ext1}" value "${ext2}"`); + self.setPlayVideo(`ply.players.${ext1}.common.`, 1); + break; + case'PLYRE' : // received Video paused + self.log.silly(`Extron got video paused for output "${ext1}" value "${ext2}"`); + self.setPlayVideo(`ply.players.${ext1}.common.`, 2); + break; + case 'PLYRO' : // received video stopped + self.log.silly(`Extron got video stopped for output "${ext1}" value "${ext2}"`); + self.setPlayVideo(`ply.players.${ext1}.common.`, 0); + break; + case 'PLYR1' : // received loop state + self.log.silly(`Extron got video loop mode for output "${ext1}" value "${ext2}"`); + self.setLoopVideo(`ply.players.${ext1}.common.`,ext2); + break; + case 'PLYRU' : // received video filepath + self.log.silly(`Extron got video video filepath for output "${ext1}" value "${ext2}"`); + self.setVideoFile(`ply.players.${ext1}.common.`,ext2); + break; } } else { if (answer != 'Q') { @@ -771,7 +792,10 @@ class Extron extends utils.Adapter { break; case 'playmode' : - self.getPlayMode(id); + if (self.devices[self.config.device].short === 'smd202') + { + self.getPlayVideo(); + } else self.getPlayMode(id); break; case 'repeatmode' : @@ -781,6 +805,13 @@ class Extron extends utils.Adapter { case 'filename' : self.getFileName(id); break; + + case 'filepath' : + self.getVideoFile(); + break; + case 'loopmode' : + self.getLoopVideo(); + break; } } } @@ -1408,6 +1439,150 @@ class Extron extends utils.Adapter { /** END CP83 Video control */ + /** BEGIN SMD2020 Video Player control */ + /** send start payback command + * cmd = S1*1PLYR + */ + sendPlayVideo() { + const self = this; + try { + self.streamSend('WS1*1PLYR'); + } catch (err) { + this.errorHandler(err, 'sendPlayVideo'); + } + } + + /** send pause payback command + * cmd = E1PLYR + */ + sendPauseVideo() { + const self = this; + try { + self.streamSend('WE11PLYR'); + } catch (err) { + this.errorHandler(err, 'sendPauseVideo'); + } + } + + /** send stop playback command + * cmd = O1PLYR + */ + sendStopVideo() { + const self = this; + try { + self.streamSend('WO1PLYR'); + } catch (err) { + this.errorHandler(err, 'sendStopVideo'); + } + } + + /** get playback state + * cmd = Y1PLYR + */ + getPlayVideo() { + const self = this; + try { + self.streamSend('WY1PLYR'); + } catch (err) { + this.errorHandler(err, 'getPlayVideo'); + } + } + + /** set playback state in database + * @param {string} id + * @param {number} mode + */ + setPlayVideo(id, mode) { + const self = this; + try { + self.setState(`${id}playmode`, mode, true); + } catch (err) { + this.errorHandler(err, 'setPlayVideo'); + } + } + + /** send loop payback command + * @param {string} id + * @param {boolean} mode + * cmd = R1*[mode]PLYR + */ + sendLoopVideo(id, mode) { + const self = this; + try { + self.streamSend(`WR${self.id2oid(id)}*${mode?1:0}PLYR`); + } catch (err) { + this.errorHandler(err, 'sendLoopVideo'); + } + } + + /** get loop payback mode + * cmd = R1*[mode]PLYR + */ + getLoopVideo() { + const self = this; + try { + self.streamSend('WR1PLYR'); + } catch (err) { + this.errorHandler(err, 'getLoopVideo'); + } + } + + /** set loop payback mode + * @param {string} id + * @param {boolean | string} mode + */ + setLoopVideo(id, mode) { + const self = this; + try { + self.setState(`${id}loopmode`, Number(mode)?true:false, true); + } catch (err) { + this.errorHandler(err, 'setLoopVideo'); + } + } + + /** send path and fileneame + * @param {string} id + * @param {string} path + * cmd = U1*[path] + */ + sendVideoFile(id, path) { + const self = this; + try { + self.streamSend(`${self.id2oid(id)}*${path}PLYR`); + } catch (err) { + this.errorHandler(err, 'sendVideoFile'); + } + } + + /** get path and fileneame + * cmd = U1PLYR + */ + getVideoFile() { + const self = this; + try { + self.streamSend('WU1PLYR'); + } catch (err) { + this.errorHandler(err, 'getVideoFile'); + } + } + + /** + * Set the Player filename in the database + * @param {string} id + * @param {string} path + */ + setVideoFile(id, path) { + const self = this; + try { + self.setState(`${id}filepath`, path, true); + self.playerLoaded[0] = (path != '' ? true : false); + } catch (err) { + this.errorHandler(err, 'setVideoFile'); + } + } + + /** END SMD 2020 Video Player Control */ + /** * determine the database id from oid e.g. 20002 -> in.inputs.01.mixPoints.O03 * @param {string} oid @@ -1767,6 +1942,12 @@ class Extron extends utils.Adapter { case 'tie' : self.sendTieCommand(baseId, state.val); break; + case 'loopmode' : + self.sendLoopVideo(baseId, state.val); + break; + case 'filepath' : + self.sendVideoFile(baseId, state.val); + break; } } }