2021-10-31 19:47:07 +00:00
|
|
|
import * as signalR from "@microsoft/signalr";
|
2021-11-09 18:17:22 +00:00
|
|
|
import * as Vue from "vue";
|
2021-11-05 07:58:48 +00:00
|
|
|
import { FullTrack, CurrentlyPlayingDTO } from "./HubInterfaces";
|
2021-11-09 20:58:02 +00:00
|
|
|
import NowPlayingCard from "./NowPlayingCard";
|
2021-10-31 19:47:07 +00:00
|
|
|
|
|
|
|
const connection = new signalR.HubConnectionBuilder()
|
|
|
|
.withUrl("/hub")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
connection.start().catch(err => console.error(err));
|
|
|
|
|
2021-11-09 20:58:02 +00:00
|
|
|
interface NowPlaying {
|
|
|
|
currentlyPlaying?: CurrentlyPlayingDTO
|
|
|
|
}
|
|
|
|
|
2021-11-09 18:17:22 +00:00
|
|
|
const app = Vue.createApp({
|
|
|
|
data() {
|
|
|
|
return {
|
2021-11-09 20:58:02 +00:00
|
|
|
currentlyPlaying: {
|
|
|
|
track: {
|
|
|
|
name: "No Playback",
|
|
|
|
album: {
|
|
|
|
name: "",
|
|
|
|
images: [
|
|
|
|
{
|
|
|
|
url: ""
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
artists: [
|
|
|
|
{
|
|
|
|
name: ""
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} as NowPlaying
|
2021-11-09 18:17:22 +00:00
|
|
|
},
|
|
|
|
created() {
|
2021-11-09 20:58:02 +00:00
|
|
|
connection.on("OnNewPlaying", (context: CurrentlyPlayingDTO) =>
|
|
|
|
{
|
|
|
|
console.log(context);
|
|
|
|
this.currentlyPlaying = context;
|
|
|
|
});
|
2021-11-09 18:17:22 +00:00
|
|
|
}
|
|
|
|
});
|
2021-11-09 20:58:02 +00:00
|
|
|
|
|
|
|
app.component("now-playing-card", NowPlayingCard);
|
2021-11-09 18:17:22 +00:00
|
|
|
const vm = app.mount('#app');
|