Fetch a random featured Twitch clip for a user, broadcast it, and autoplay it in an OBS browser overlay. Unloads after playback to free resources.
clip_overlay.cs– C# Code sub-action.clip_overlay.html– OBS overlay page.streamerbot.export– sample chat command/action import code.
- Streamer.bot with C# actions enabled.
- WebSocket Server enabled in Streamer.bot.
- HTTP Server enabled in Streamer bot
- OBS Studio with Browser Source.
Server/Clients → WebSocket Server → Enable.
Default host: 127.0.0.1. Default port: 8080. Add a password if desired.
Server/Clients → HTTP Server → Enable.
Default host: 127.0.0.1. Default port: 7474.
Path Mapping: create PATH: clip_overlay to a new folder.
Place clip_overlay.html in the new folder.
(the html-file in the new folder is now accesible via `http://localhost:7474/clip_overlay/clip_overlay.html)
Create an Action → add C# Code sub-action → paste contents of clip_overlay.cs
Triggering options
-
Manual: Run Action with set variable name
twitchUserand valuetwitchUsername. -
Chat command example:
- Add a Command like
!featuredclip {user}. - set argument
{user}totwitchUserargument in the action.
- Add a Command like
see streamerbot.export - import the code to streamer.bot to get a working !shoutout command and a simple action.
-
Add a browser source to OBS: http://localhost:7474/clip_overlay/clip_overlay.html?parent=localhost&host=127.0.0.1&port=8080
-
In Streamer.bot, run the action The overlay autoplays a random featured clip and then unloads.
Query params on the overlay:
host– Streamer.bot WS host. Defaultlocalhost.port– Streamer.bot WS port. Default8080.password– Streamer.bot WS password if set.parent– Required Twitch embed host. Must match page host.muted–trueorfalse. Defaultfalse. Unmuted autoplay is not reliable.fallbackSeconds– Used when clip duration is missing. Default30.
Action args:
twitchUser– Twitch login of the broadcaster to pull clips for. Required.count– Fetch pool size before random pick. Default50.
- Twitch Clips embed is iframe-only.
file://cannot be used to provide the overlay. Twitch CPSparentrequires a domain.- Unmuted autoplay may be blocked by browser policies. Expect muted autoplay or manual unmute.
- The overlay removes the iframe after playback, its a simple timer, if loading takes too long or buffering occurs, the clips mights be cut short.
Blank player or “refused to connect”
parentmismatch. The value must equal the overlay page host.- Using
file://. Serve over HTTP.
Overlay never receives events
- Wrong WS host/port/password in URL.
- WebSocket Server disabled in Streamer.bot.
- Firewall blocks localhost port.
Clip never unloads
- Clip has no duration. Set
fallbackSecondsor supply duration in payload.
- Keep the WebSocket on localhost.
- If you must expose it, set a strong WS password and limit network access.
Use, modify, and ship as you see fit.