Adds feature flags, and the ability to do browser playback

This commit is contained in:
2025-06-24 12:50:15 -07:00
parent 480b30d909
commit 5e9842f02d
9 changed files with 1142 additions and 668 deletions

View File

@@ -39,6 +39,12 @@ enum UserEvent {
MPDUpdate = "mpd_update",
}
export interface Features {
video: boolean;
screenshare: boolean;
browserPlayback: boolean;
}
export class MediaPlayer {
private playerProcess: ChildProcess | null = null;
private socket: Promise<Socket>;
@@ -59,6 +65,10 @@ export class MediaPlayer {
this.favoritesStore.onFavoritesChanged = (favorites) => {
this.handleEvent(UserEvent.FavoritesUpdate, { favorites });
};
this.getFeatures().then(features => {
console.log("Features: ", features);
});
}
public startZeroconfService(port: number) {
@@ -304,6 +314,14 @@ export class MediaPlayer {
return this.modify(UserEvent.FavoritesUpdate, () => this.favoritesStore.updateFavoriteTitle(filename, title));
}
public async getFeatures(): Promise<Features> {
return {
video: !!process.env.ENABLE_VIDEO,
screenshare: !!process.env.ENABLE_SCREENSHARE,
browserPlayback: !!process.env.ENABLE_BROWSER_PLAYBACK
};
}
private async loadFile(url: string, mode: string, fetchMetadata: boolean = true, options: string[] = []) {
this.modify(UserEvent.PlaylistUpdate, () => this.writeCommand("loadfile", [url, mode, "-1", options.join(',')]));

View File

@@ -281,6 +281,11 @@ apiRouter.put("/favorites/:filename/title", withErrorHandling(async (req, res) =
res.send(JSON.stringify({ success: true }));
}));
apiRouter.get("/features", withErrorHandling(async (req, res) => {
const features = await mediaPlayer.getFeatures();
res.send(JSON.stringify(features));
}));
// Serve static files for React app (after building)
app.use(express.static(path.join(__dirname, "../dist/frontend")));