Feature: adds screen sharing

This commit is contained in:
2025-05-12 20:27:09 -07:00
parent db3b10d324
commit 035d74d412
6 changed files with 345 additions and 23 deletions

View File

@@ -53,6 +53,7 @@ export enum ServerEvent {
FavoritesUpdate = "favorites_update",
MetadataUpdate = "metadata_update",
MPDUpdate = "mpd_update",
ScreenShare = "screen_share",
}
export const API = {
@@ -90,6 +91,10 @@ export const API = {
async play(): Promise<void> {
await fetch('/api/play', { method: 'POST' });
},
async stop(): Promise<void> {
await fetch('/api/stop', { method: 'POST' });
},
async pause(): Promise<void> {
await fetch('/api/pause', { method: 'POST' });
@@ -168,5 +173,11 @@ export const API = {
},
body: JSON.stringify({ title }),
});
},
startScreenShare(mimeType: string): WebSocket {
const protocol = window.location.protocol === 'https:' ? 'wss' : 'ws';
const ws = new WebSocket(`${protocol}://${window.location.host}/api/screenshare?mimeType=${mimeType}`);
return ws;
}
};