-
- Selected:
-
-
-
-
-
+
+
+
{
+ this.selectedSong = ev.detail.song;
+ }}
+ .selectedSong=${this.selectedSong}
+ >
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+ ${this.renderPlayerStateTable()}
+
-
-
-
-
-
-
-
-
`;
+ `;
+ }
+ renderPlayerStateTable() {
+ return html`
+
+ duration |
+ ${this.playerState.duration} |
+
+
+ endOfSong |
+ ${this.playerState.endOfSong} |
+
+
+ pausedSongTime |
+ ${this.playerState.pausedSongTime?.toFixed(3)} |
+
+
+ playing |
+ ${this.playerState.playing} |
+
+
+ song |
+ ${this.playerState.song?.value} |
+
+
+ wallStartTime |
+ ${this.playerState.wallStartTime} |
+
+
+ t |
+ ${this.playerTime.toFixed(3)} |
+
+
`;
}
onSelectSong(song: NamedNode, ev: MouseEvent) {
@@ -189,122 +178,46 @@ export class Light9AscoltamiUi extends L
this.selectedSong = song;
}
}
- async onPlaySelected(ev: Event) {
+
+ async onLoadSelected() {
if (!this.selectedSong) {
return;
}
- await fetch("../service/ascoltami/song", { method: "POST", body: this.selectedSong.value });
+ await fetch("/service/ascoltami/song", { method: "POST", body: this.selectedSong.value });
+ this.selectedSong = null;
}
onCmdStop(ev?: MouseEvent): void {
- postJson("../service/ascoltami/time", { pause: true });
+ postJson("/service/ascoltami/time", { pause: true });
}
+
onCmdPlay(ev?: MouseEvent): void {
- postJson("../service/ascoltami/time", { resume: true });
- }
- onCmdIntro(ev?: MouseEvent): void {
- postJson("../service/ascoltami/time", { t: this.times.intro, resume: true });
+ postJson("/service/ascoltami/time", { resume: true });
}
- onCmdPost(ev?: MouseEvent): void {
- postJson("../service/ascoltami/time", {
- t: this.currentDuration - this.times.post,
- resume: true,
- });
+
+ onCmdGo(ev?: MouseEvent): void {
+ postJson("/service/ascoltami/go", {});
}
- onCmdGo(ev?: MouseEvent): void {
- postJson("../service/ascoltami/go", {});
+
+ onCmdZero(ev?: MouseEvent): void {
+ postJson("/service/ascoltami/time", { t: 0 });
}
bindKeys() {
document.addEventListener("keypress", (ev) => {
- if (ev.which == 115) {
+ if (ev.key == "l") {
+ this.onLoadSelected();
+ } else if (ev.key == "z") {
+ this.onCmdZero();
+ } else if (ev.key == "p") {
+ this.onCmdPlay();
+ } else if (ev.key == "s") {
this.onCmdStop();
- return false;
- }
- if (ev.which == 112) {
- this.onCmdPlay();
- return false;
+ } else if (ev.key == "g") {
+ this.onCmdGo();
+ } else {
+ return true;
}
- if (ev.which == 105) {
- this.onCmdIntro();
- return false;
- }
- if (ev.which == 116) {
- this.onCmdPost();
- return false;
- }
-
- if (ev.key == "g") {
- this.onCmdGo();
- return false;
- }
- return true;
});
}
-
- async musicSetup() {
- // shoveled over from the vanillajs version
- const config = await (await fetch("../service/ascoltami/config")).json();
- this.show = new NamedNode(config.show);
- this.times = config.times;
- document.title = document.title.replace("{{host}}", config.host);
- try {
- const h1 = document.querySelector("h1")!;
- h1.innerText = h1.innerText.replace("{{host}}", config.host);
- } catch (e) {}
-
- (window as any).finishOldStyleSetup(this.times, this.onOldStyleUpdate.bind(this));
- }
-
- onOldStyleUpdate(data: TimingUpdate) {
- this.nextText = data.next;
- this.isPlaying = data.playing;
- this.currentDuration = data.duration;
- this.song = new NamedNode(data.song);
- this.overviewZoom = { duration: data.duration, t1: 0, t2: data.duration };
- const t1 = data.t - 2,
- t2 = data.t + 20;
- this.zoom = { duration: data.duration, t1, t2 };
- const timeRow = this.shadowRoot!.querySelector(".timeRow") as HTMLDivElement;
- const w = timeRow.offsetWidth;
- this.viewState = {
- zoomSpec: { t1: () => t1, t2: () => t2 },
- cursor: { t: () => data.t },
- audioY: () => 0,
- audioH: () => 60,
- zoomedTimeY: () => 60,
- zoomedTimeH: () => 40,
- fullZoomX: (sec: number) => (sec / data.duration) * w,
- zoomInX: (sec: number) => ((sec - t1) / (t2 - t1)) * w,
- mouse: { pos: () => $V([0, 0]) },
- };
- }
-
- @property() songList: NamedNode[] = [];
- constructor() {
- super();
- this.bindKeys();
- this.zoom = this.overviewZoom = { duration: null, t1: 0, t2: 1 };
-
- getTopGraph().then((g) => {
- this.graph = g;
- this.musicSetup(); // async
- this.graph.runHandler(this.graphChanged.bind(this), "loadsongs");
- });
- }
- graphChanged() {
- this.songList = [];
- try {
- const playList = this.graph.uriValue(
- //
- this.graph.Uri(showRoot),
- this.graph.Uri(":playList")
- );
- log(playList);
- this.songList = this.graph.items(playList) as NamedNode[];
- } catch (e) {
- log("no playlist yet");
- }
- log(this.songList.length);
- }
}