[PoC] Web app remote control (#203)
* [PoC] Web app remote control * Remote UI cleanup * changelog
This commit is contained in:
1 parent
2a57cc99c7
commit
413e73c1c0
23 files changed
+370
-1
No files matched your search
@@ -7,4 +7,11 @@ export class ExternalControlProtocol {
|
||||
body: '',
|
||||
})
|
||||
}
|
||||
|
||||
static async pressKey(key) {
|
||||
return fetch(`http://${getIp()}:8060/keypress/${key}`, {
|
||||
method: 'POST',
|
||||
body: '',
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
import SearchIcon from "../assets/search-icon.svg.svelte";
|
||||
import SettingsIcon from "../assets/settings-icon.svg.svelte";
|
||||
import BookmarksIcon from "../assets/star-icon.svg.svelte";
|
||||
import RemoteIcon from "../assets/remote-control.svg.svelte";
|
||||
|
||||
import { appStateStore } from "lib/Stores";
|
||||
import type { AppState } from "lib/Types";
|
||||
@@ -55,6 +56,14 @@
|
||||
<SettingsIcon />
|
||||
</div>
|
||||
</button>
|
||||
<button
|
||||
on:click={() => setScreen("remote")}
|
||||
class={$appStateStore.screen === "remote" ? "active" : ""}
|
||||
>
|
||||
<div class="h-6">
|
||||
<RemoteIcon />
|
||||
</div>
|
||||
</button>
|
||||
<button
|
||||
on:click={() => setScreen("info")}
|
||||
class={$appStateStore.screen === "info" ? "active" : ""}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<script lang="ts">
|
||||
import { ExternalControlProtocol } from "lib/Api/ExternalControlProtocol";
|
||||
|
||||
export let key: string;
|
||||
export let icon;
|
||||
|
||||
function pressKey() {
|
||||
console.log(`Sending key: ${key}`);
|
||||
ExternalControlProtocol.pressKey(key);
|
||||
}
|
||||
</script>
|
||||
|
||||
<button
|
||||
on:click={pressKey}
|
||||
class="w-28 h-11 btn-primary rounded-xl flex items-center justify-center"
|
||||
>
|
||||
<svelte:component this={icon} />
|
||||
</button>
|
||||
@@ -0,0 +1,79 @@
|
||||
<script lang="ts">
|
||||
import { ExternalControlProtocol } from "lib/Api/ExternalControlProtocol";
|
||||
|
||||
import HomeIcon from "assets/remote-control/home.svg.svelte";
|
||||
import ArrowBackIcon from "assets/remote-control/arrow-back.svg.svelte";
|
||||
import ArrowUpIcon from "assets/remote-control/arrow-up.svg.svelte";
|
||||
import ArrowDownIcon from "assets/remote-control/arrow-down.svg.svelte";
|
||||
import ArrowLeftIcon from "assets/remote-control/arrow-left.svg.svelte";
|
||||
import ArrowRightIcon from "assets/remote-control/arrow-right.svg.svelte";
|
||||
import OkIcon from "assets/remote-control/ok.svelte";
|
||||
import InstantReplayIcon from "assets/remote-control/instant-replay.svg.svelte";
|
||||
import OptionsIcon from "assets/remote-control/options.svg.svelte";
|
||||
import FastForwardIcon from "assets/remote-control/fast-forward.svg.svelte";
|
||||
import FastBackwardIcon from "assets/remote-control/fast-backward.svg.svelte";
|
||||
import PlayIcon from "assets/remote-control/play.svg.svelte";
|
||||
import VolumeDownIcon from "assets/remote-control/volume-down.svg.svelte";
|
||||
import VolumeMuteIcon from "assets/remote-control/volume-mute.svg.svelte";
|
||||
import VolumeUpIcon from "assets/remote-control/volume-up.svg.svelte";
|
||||
|
||||
import RemoteButton from "./RemoteControl/RemoteButton.svelte";
|
||||
|
||||
export let visibility: boolean;
|
||||
|
||||
const BUTTONS = {
|
||||
home: "Home",
|
||||
rev: "Rev",
|
||||
fwd: "Fwd",
|
||||
play: "Play",
|
||||
select: "Select",
|
||||
left: "Left",
|
||||
right: "Right",
|
||||
down: "Down",
|
||||
up: "Up",
|
||||
back: "Back",
|
||||
instantReplay: "InstantReplay",
|
||||
info: "Info",
|
||||
backspace: "Backspace",
|
||||
search: "Search",
|
||||
enter: "Enter",
|
||||
volumeDown: "VolumeDown",
|
||||
volumeMute: "VolumeMute",
|
||||
volumeUp: "VolumeUp",
|
||||
powerOff: "PowerOff",
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class={visibility ? "" : "hidden"}>
|
||||
<div class="flex flex-col items-center justify-center p-6">
|
||||
<div class="flex space-x-2 m-2">
|
||||
<RemoteButton key={BUTTONS.back} icon={ArrowBackIcon} />
|
||||
<RemoteButton key={BUTTONS.home} icon={HomeIcon} />
|
||||
</div>
|
||||
<div class="flex space-x-2 m-2">
|
||||
<RemoteButton key={BUTTONS.up} icon={ArrowUpIcon} />
|
||||
</div>
|
||||
<div class="flex space-x-2 m-2">
|
||||
<RemoteButton key={BUTTONS.left} icon={ArrowLeftIcon} />
|
||||
<RemoteButton key={BUTTONS.select} icon={OkIcon} />
|
||||
<RemoteButton key={BUTTONS.right} icon={ArrowRightIcon} />
|
||||
</div>
|
||||
<div class="flex space-x-2 m-2">
|
||||
<RemoteButton key={BUTTONS.down} icon={ArrowDownIcon} />
|
||||
</div>
|
||||
<div class="flex space-x-2 m-2">
|
||||
<RemoteButton key={BUTTONS.instantReplay} icon={InstantReplayIcon} />
|
||||
<RemoteButton key={BUTTONS.info} icon={OptionsIcon} />
|
||||
</div>
|
||||
<div class="flex space-x-2 m-2">
|
||||
<RemoteButton key={BUTTONS.rev} icon={FastBackwardIcon} />
|
||||
<RemoteButton key={BUTTONS.play} icon={PlayIcon} />
|
||||
<RemoteButton key={BUTTONS.fwd} icon={FastForwardIcon} />
|
||||
</div>
|
||||
<div class="flex space-x-2 m-2">
|
||||
<RemoteButton key={BUTTONS.volumeMute} icon={VolumeMuteIcon} />
|
||||
<RemoteButton key={BUTTONS.volumeDown} icon={VolumeDownIcon} />
|
||||
<RemoteButton key={BUTTONS.volumeUp} icon={VolumeUpIcon} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,5 +1,5 @@
|
||||
export type AppState = {
|
||||
screen: "search" | "home" | "bookmarks" | "settings" | "info"
|
||||
screen: "search" | "home" | "bookmarks" | "settings" | "info" | "remote"
|
||||
}
|
||||
|
||||
export type PlayletState = {
|
||||
|
||||
Reference in new issue
Block a user