From e6b85748813a23b97cedf53f4b0b0db6639c2d0b Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 25 Feb 2022 10:16:19 +0000 Subject: [PATCH] retrive platform options from device --- HELP.md | 4 ++-- index.js | 37 +++++++++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/HELP.md b/HELP.md index fb362ba..7ac93d8 100644 --- a/HELP.md +++ b/HELP.md @@ -2,7 +2,7 @@ Module to control and monitor the [Blackmagic Design Web Presenter HD and 4K](https://www.blackmagicdesign.com/products/blackmagicwebpresenter). This module does not support the discontinued USB only **Web Presenter** product. -Once connection to the device has been established the stream 'Video Mode' and 'Quality' action parameters will be populated with the options that the device supports. If no device connection is possible then these parameters will be unavailable. +Once connection to the device has been established the stream 'Video Mode', 'Quality' and 'Platform' action parameters will be populated with the options that the device supports. If no device connection is possible then these parameters will be unavailable. ## Version 1.0.0 This first release of the module allows you to start/stop the stream and to receive the stream state as a variable and feedback. Please log issues and feature requests on [github](https://github.com/bitfocus/companion-module-bmd-webpresenterhd). @@ -17,5 +17,5 @@ Internal changes ## Version 1.0.3 Add support for both 4K and HD Add more variables for monitoring -Retrieve the 'Video Mode' and 'Quality' options from device +Retrieve the 'Video Mode', 'Quality' and 'Platform' options from device diff --git a/index.js b/index.js index ddd2b87..a754a81 100644 --- a/index.js +++ b/index.js @@ -14,6 +14,7 @@ function instance(system) { self.command = null self.formats = [] self.quality = [] + self.platforms = [] // super-constructor instance_skel.apply(this, arguments) @@ -68,6 +69,19 @@ instance.prototype.deviceInformation = function (key, data) { self.actions() } + if (data['Available Default Platforms'] !== undefined) { + p = data['Available Default Platforms'].split(',') + self.platforms = [] + for (var i = 0; i < p.length; i++) { + self.platforms.push({ id: p[i].trim(), label: p[i].trim() }) + } + self.has_data = true + + console.log('platforms available from device:') + console.log(self.platforms) + self.actions() + } + if (data['Video Mode'] !== undefined) { self.setVariable('video_mode', data['Video Mode']) self.has_data = true @@ -197,8 +211,8 @@ instance.prototype.init_tcp = function () { self.stash = [] self.command = null - } else { - console.log('weird response from device: ' + line) + } else if (line.length > 0) { + console.log('weird response from device: ' + line.toString() + ' ' + line.length) } }) } @@ -422,16 +436,25 @@ instance.prototype.actions = function () { choices: self.formats, }, { - type: 'textinput', + type: 'dropdown', label: 'Platform', id: 'platform', default: 'YouTube', + choices: self.platforms, }, { type: 'textinput', label: 'Server', id: 'server', - default: 'Primary', + default: '', + tooltip: 'Depends on platform.\nRefer to Blackmagic Web Presenter desktop application for possible options.', + }, + { + type: 'textinput', + label: 'Stream Key', + id: 'key', + default: '', + tooltip: 'Provided by the streaming platform.', }, { type: 'dropdown', @@ -440,12 +463,6 @@ instance.prototype.actions = function () { default: 'Streaming Medium', choices: self.quality, }, - { - type: 'textinput', - label: 'Stream Key', - id: 'key', - default: '', - }, ], }, device: {