From 93d34306bc48757d69bba6cbe33ab16fd1bcbcf1 Mon Sep 17 00:00:00 2001 From: ReaperOfVeriod Date: Sun, 25 Oct 2026 04:47:28 +0100 Subject: [PATCH] feat: embed Twitch stream player --- src/App.svelte | 8 ++++++-- src/styles.css | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/App.svelte b/src/App.svelte index d896484..99b50b8 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -24,6 +24,8 @@ let streamLanguage = 'en'; let streamTags = ''; let streamClassificationLabels = ''; + let streamerName = ''; + let playerSrc = ''; let categorySearch = ''; let categoryOptions: Array<{ id: string; name: string; box_art_url: string }> = []; let categorySearchTimer: number | undefined; @@ -174,7 +176,9 @@ headers: { authorization: `Bearer ${sessionToken}` }, }); if (!response.ok) return; - const info: { title: string; game_id: string; game_name: string; language: string; tags: string[]; content_classification_labels: string[] } = await response.json(); + const info: { broadcaster_name: string; title: string; game_id: string; game_name: string; language: string; tags: string[]; content_classification_labels: string[] } = await response.json(); + streamerName = info.broadcaster_name; + playerSrc = `https://player.twitch.tv/?channel=${encodeURIComponent(info.broadcaster_name)}&parent=${encodeURIComponent(window.location.hostname)}&muted=true`; streamTitle = info.title; streamGameId = info.game_id; categorySearch = info.game_name; @@ -333,7 +337,7 @@ {:else}
-
STREAM PREVIEW⋮
STREAM OFFLINE
CONNECT TWITCH TO BEGIN
+
STREAM PREVIEW⋮
{#if playerSrc}{:else}
STREAM OFFLINE
CONNECT TWITCH TO BEGIN
{/if}
ACTIVITY FEED⋮
{#if activityEvents.length}
{#each activityEvents as event}
{event.event_type}{new Date(event.occurred_at).toLocaleTimeString()}
{/each}
{:else}
◌
Nothing here yetFollows, subscriptions, raids, and server events will appear here.
{/if}
MY CHAT⋮
⌁
Chat is waitingConnect a streamer or bot account to begin.
QUICK ACTIONS⋮
{#if showStreamEditor}
searchCategories(event.currentTarget.value)} autocomplete="off" placeholder="Search Twitch categories" />{#if categoryOptions.length}
{#each categoryOptions as category}{/each}
{/if}{#if streamError}
{streamError}
{/if}
{/if}
diff --git a/src/styles.css b/src/styles.css index a353704..bf752af 100644 --- a/src/styles.css +++ b/src/styles.css @@ -366,6 +366,14 @@ label { background: color-mix(in srgb, var(--ed-accent) 3%, var(--ed-bg)); text-align: center; } +.twitch-player { + display: block; + width: 100%; + min-height: 260px; + flex: 1; + border: 0; + background: #000; +} .offline-mark { color: var(--ed-fg); font: 700 24px var(--font-display);