bitfocus / companion

Bitfocus Companion enables the reasonably priced Elgato Stream Deck and other controllers to be a professional shotbox surface for an increasing amount of different presentation switchers, video playback software and broadcast equipment.
http://bitfocus.io/companion
Other
1.57k stars 499 forks source link

Internal Button action : Change PNG #2906

Closed pylaflamme closed 3 months ago

pylaflamme commented 3 months ago

Is this a feature relevant to companion itself, and not a module?

Is there an existing issue for this?

Describe the feature

It's actually possible to change the text, the text color and the background, but I would like to change the PNG of a button on the StreamDeck, and eventually on another StreamDeck on the network.

Usecases

To let different operator on the show to identify their status to a show caller.

dnmeid commented 3 months ago

We want to discourage direct access to other buttons as this leads to a complex and error prone style of programming. It is possible to change PNGs with feedbacks, e.g. based on a custom variable. That does the same and has the benefit that you can move your buttons later and keep the functionality.

scientastic commented 3 months ago

I have the same issue. Here's what I'm trying to accomplish.

Basically, I'm looking for a way to dynamically set the PNG for a button from either an action, or an external script via the HTTP API. It can input base64 encoded PNG, a filename, a URL, etc.

scientastic commented 3 months ago

We want to discourage direct access to other buttons as this leads to a complex and error prone style of programming. It is possible to change PNGs with feedbacks, e.g. based on a custom variable. That does the same and has the benefit that you can move your buttons later and keep the functionality.

This is all well and good for most normal uses. I understand the reticence to expose functionality that can be abused. But there are some legitimate cases that cannot (apparently) be handled any other way.

thedist commented 3 months ago

Have you considered making a custom module? As it would be trivial to do the sort of thing you're looking to accomplish within a module, and is already what many productions do for needs that can not be met using the default Companion actions/feedbacks.

scientastic commented 3 months ago

Have you considered making a custom module? As it would be trivial to do the sort of thing you're looking to accomplish within a module, and is already what many productions do for needs that can not be met using the default Companion actions/feedbacks.

I'm a developer but have not gotten that far deep into Companion. Where would I start to develop a custom module? How is it deployed? Documentation on this process... ? Thanks!

scientastic commented 3 months ago

We want to discourage direct access to other buttons as this leads to a complex and error prone style of programming. It is possible to change PNGs with feedbacks, e.g. based on a custom variable. That does the same and has the benefit that you can move your buttons later and keep the functionality.

The other thought that I have in response to this is that buttons support changing the text dynamically... what is so different about changing the image? It's essentially just another attribute of the button. In our case, because we have Korean text that doesn't work in the text field (shows up as Unicode boxes as character placeholders), we are forced to use images already in many cases where text would be preferable.

thedist commented 3 months ago

I'm a developer but have not gotten that far deep into Companion. Where would I start to develop a custom module? How is it deployed? Documentation on this process... ? Thanks!

The Wiki has a Module Development 101 guide https://github.com/bitfocus/companion-module-base/wiki/Module-development-101, that's a great place to start. For private modules that you don't need included in Companions official builds are quite easy to make and there's templates available.

The other thought that I have in response to this is that buttons support changing the text dynamically... what is so different about changing the image? It's essentially just another attribute of the button. In our case, because we have Korean text that doesn't work in the text field (shows up as Unicode boxes as character placeholders), we are forced to use images already in many cases where text would be preferable.

I don't know the reasoning, it's not something that was discussed as far as I'm aware.

One other option I just thought of, is in the Companion settings you can enable the deprecated API, so while not a permanent solution (unless you fork Companion and prevent it being removed in the future) that will give you a HTTP endpoint to edit the PNG64 of any button, provided you have a png64 encoded PNG. For example a GET request to http://127.0.0.1:8000/style/bank/1/9?png64=... would set the png of button 9 on page 1 to whatever you want it to be (assuming Companion is running on that IP:Port and the deprecated API is enabled).

I was the one that added that API functionality, and at the time provided the ability to change all style properties.

Julusian commented 3 months ago

@thedist

One other option I just thought of, is in the Companion settings you can enable the deprecated API, so while not a permanent solution

That functionality is also in the non-deprecated portion of the api. Nothing got removed in the revised api

thedist commented 3 months ago

That functionality is also in the non-deprecated portion of the api. Nothing got removed in the revised api

Ah, perfect, even better then! In that case the docs for using that as change the PNG of any button can be found on the Getting Started page in the Companion Web UI > Remote Control > HTTP Remote Control.

scientastic commented 3 months ago

That functionality is also in the non-deprecated portion of the api. Nothing got removed in the revised api

Ah, perfect, even better then! In that case the docs for using that as change the PNG of any button can be found on the Getting Started page in the Companion Web UI > Remote Control > HTTP Remote Control.

Thanks... API access would be perfect for me since I already have a background process that I use for various purposes, talking to StreamDeck and other moving parts.

I actually checked there (Remote Control > HTTP Remote Control) before, and the API to change PNG is apparently not documented there. (docs/5_remote_control/http_remote_control.md)

In the code (companion/lib/Service/HttpApi.js) is it the style route with a png64 query (e.g. /api/location/<page>/<row>/<column>/style?png64=<base64_png>)? Is the png64 value just a straight-up (URL-encoded) base64 version of the PNG binary file?