Skip to content

Example 6: Creating an animated key

Roland edited this page Sep 17, 2018 · 2 revisions

THIS TUTORIAL IS OUTDATED ATM

This example will create a key with an endless looping animation from a gif:

For this we use an ExecutableItem, the icon "resources/icon.png" and the gif "resources/icon.gif".

For the animation to be displayed we use the StreamDeckController.


Includes:

import de.rcblum.stream.deck.StreamDeck;
import de.rcblum.stream.deck.StreamDeckController;
import de.rcblum.stream.deck.StreamDeckDevices;
import de.rcblum.stream.deck.items.ExecutableItem;
import de.rcblum.stream.deck.items.FolderItem;
import de.rcblum.stream.deck.items.StreamItem;
import de.rcblum.stream.deck.items.animation.AnimationStack;
import de.rcblum.stream.deck.util.IconHelper;

Load animation frames from gif and create animation data for an animation looping at 30 fps:

byte[][] animationFrames = IconHelper.loadImagesFromGif(
	"resources" + File.separator + "icon.gif"
);
AnimationStack as = new AnimationStack(
	AnimationStack.REPEAT_LOOPING, 
	AnimationStack.FRAME_RATE_30, 
	AnimationStack.TRIGGER_AUTO, 
	animationFrames
);

Create ExecutableItem with animation:

ExecutableItem item0 = new ExecutableItem(
	IconHelper.loadImage("resources" + File.separator + "icon.png"), 
	as, 
	"explorer.exe"
);

Create root folder with item, initialzie StreamDeck and create controller:

StreamItem[] items = new StreamItem[15];
items[7] = item0;
FolderItem root = new FolderItem(null, null, items);
StreamDeck sd = StreamDeckDevices.getStreamDeck();
sd.reset();
StreamDeckController sdc = new StreamDeckController(sd, root);

Clone this wiki locally