start integrating websocket, player basically done

This commit is contained in:
2024-06-27 16:50:03 +02:00
parent 76f543eb2f
commit 1e11f1dc2e
13 changed files with 567 additions and 48 deletions

View File

@@ -228,6 +228,7 @@ class MusicKitJSWrapper {
switch ( action ) {
case "play":
if ( this.isPreparedToPlay ) {
this.control( 'pause' );
if ( this.playlist[ this.playingSongID ].origin === 'apple-music' ) {
this.musicKit.play();
return false;
@@ -285,6 +286,7 @@ class MusicKitJSWrapper {
return false;
}
case "next":
this.control( 'pause' );
if ( this.queuePos < this.queue.length - 1 ) {
this.queuePos += 1;
this.prepare( this.queue[ this.queuePos ] );
@@ -300,6 +302,7 @@ class MusicKitJSWrapper {
return true;
}
case "previous":
this.control( 'pause' );
if ( this.queuePos > 0 ) {
this.queuePos -= 1;
this.prepare( this.queue[ this.queuePos ] );

View File

@@ -15,7 +15,25 @@ class NotificationHandler {
socket: Socket;
constructor () {
this.socket = io();
this.socket = io( localStorage.getItem( 'url' ) ?? '', {
autoConnect: false,
} );
}
/**
* Create a room token and connect to
* @param {string} roomName
* @returns {Promise<string>}
*/
connect ( roomName: string ): Promise<string> {
fetch( localStorage.getItem( 'url' ) + '/createRoomToken', { credentials: 'include' } ).then( res => {
if ( res.status === 200 ) {
res.json().then( json => {
} );
}
} );
}
/**
@@ -35,10 +53,6 @@ class NotificationHandler {
disconnect (): void {
this.socket.disconnect();
}
joinRoom ( roomName: string ): void {
// this.socket.
}
}
export default NotificationHandler;

View File

@@ -42,6 +42,14 @@ export interface Song {
additionalInfo?: string;
}
export interface SongTransmitted {
title: string;
artist: string;
duration: number;
cover: string;
additionalInfo?: string;
}
export interface ReadFile {
url: string;