Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal Button action : Change PNG #2906

Closed
2 tasks done
pylaflamme opened this issue Jun 8, 2024 · 10 comments
Closed
2 tasks done

Internal Button action : Change PNG #2906

pylaflamme opened this issue Jun 8, 2024 · 10 comments

Comments

@pylaflamme
Copy link

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

  • I believe this to be a feature for companion, not a module

Is there an existing issue for this?

  • I have searched the existing issues

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
Copy link
Member

dnmeid commented Jun 9, 2024

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.

@dnmeid dnmeid closed this as not planned Won't fix, can't repro, duplicate, stale Jun 9, 2024
@scientastic
Copy link

scientastic commented Jun 25, 2024

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

  • Livestreaming setting. At the beginning we have a list of names of people who will be on stage.
  • We use different presets for PTZ cameras based on the heights of the people on stage.
  • We want to have a set of 4-5 buttons with the people's faces.
  • When their button is pressed, it sets variables pointing to the presets for the height of that person. (This is all set up already)
  • The only piece missing is being able to set the image for the person's face on the button. This has to be dynamic, as it changes frequently and new people come in from time to time.
  • We can't just use their name either because their names are in Korean (not supported in the text field, since the font is not a Unicode font). If we were just to put their name, it would have to also be as a PNG generated from the text of their name (external script). Our operators/volunteers don't always know their names and so having the face on the button would make it easiest.

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
Copy link

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
Copy link
Member

thedist commented Jun 25, 2024

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
Copy link

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
Copy link

scientastic commented Jun 25, 2024

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
Copy link
Member

thedist commented Jun 25, 2024

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
Copy link
Member

@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
Copy link
Member

thedist commented Jun 25, 2024

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
Copy link

scientastic commented Jun 27, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants