elgatosf / streamdeck-pisamples

Stream Deck SDK: PISamples sample plugin
https://developer.elgato.com/documentation/stream-deck/
MIT License
69 stars 27 forks source link

get global settings #3

Closed NijsJonas closed 1 year ago

NijsJonas commented 3 years ago

how can i store settings / values to be used again when the streamdeck app restarts ? i tried setglobalsettings but these settings are not stored when restarting the software

tiptronic commented 3 years ago

https://developer.elgato.com/documentation/stream-deck/sdk/events-sent/#getglobalsettings

tiptronic commented 3 years ago

All settings should survive a re-launch of the software

Timac commented 3 years ago

If you want to save data persistently for each action instance, you should use the setSettings API: https://developer.elgato.com/documentation/stream-deck/sdk/events-sent/#setsettings

If you want to save persistent data globally for the plugin and not just to one instance of an action, you should use setGlobalSettings. This API can be used for example to save tokens. See https://developer.elgato.com/documentation/stream-deck/sdk/events-sent/#setglobalsettings

NijsJonas commented 3 years ago

thanks, so i have that working now, another problem i have is that i cant change the image thru code when i execute this code:

var json = { "event": "setImage", "context": pluginUUID, "payload": { "image": "data:image/svg+xml;charset=utf8,<svg height=\"100\" width=\"100\"><circle cx=\"50\" cy=\"50\" r=\"40\" stroke=\"black\" stroke-width=\"3\" fill=\"red\" /></svg>", "target": 0, "state": 0 } }; websocket.send(JSON.stringify(json));

it does nothing, image doesnt change and the console doesnt show an error, when i use alert(event) in my main code i see all the events but this event never shows up so it never reaches the main code.

How can i solve this ?

Timac commented 3 years ago

@yyy898 For the context, I see that you pass a pluginUUID. You should make sure that the pass the context of the action instance, not the plugin UUID. Maybe this is the issue.

I would recommend to check out the Counter plugin source code where we use the setTitle API. If you manage to use the setTitle API, using the setImage API is similar: https://github.com/elgatosf/streamdeck-counter/blob/master/Sources/com.elgato.counter.sdPlugin/code.html

NijsJonas commented 3 years ago

i used the plugin as base for my plugin but both of these codes dont work to change the title: onKeyUp : function(state, action, context, settings, coordinates, userDesiredState) { counterAction.SetTitle(context, 0); //up }, or

onKeyUp : function(state, action, context, settings, coordinates, userDesiredState) { var json = { "event": "setTitle", "context": context, "payload": { "title": "5", "target": DestinationEnum.HARDWARE_AND_SOFTWARE } }; websocket.send(JSON.stringify(json)); }