mirror of
https://github.com/janishutz/MusicPlayerV2.git
synced 2025-11-26 05:14:24 +00:00
start integrating websocket, player basically done
This commit is contained in:
@@ -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 ] );
|
||||
|
||||
@@ -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;
|
||||
8
MusicPlayerV2-GUI/src/scripts/song.d.ts
vendored
8
MusicPlayerV2-GUI/src/scripts/song.d.ts
vendored
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user