mirror of
https://github.com/nuttylmao/nutty.gg.git
synced 2026-09-18 19:50:58 -04:00
Fixed session priority
This commit is contained in:
+11
-6
@@ -379,15 +379,20 @@ async function UpdatePlayerState(data) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Fallback when no included list is provided:
|
// Fallback when no included list is provided:
|
||||||
// Priority 1: Find any session that is currently playing
|
// Priority 1: Check Windows' current focused session ID first
|
||||||
targetSession = validSessions.find(s => s.playback_info && s.playback_info.PlaybackStatus === PlaybackStatus.PLAYING);
|
if (data.current_session_id) {
|
||||||
|
|
||||||
// Priority 2: If nothing is playing, use system's current active session ID
|
|
||||||
if (!targetSession) {
|
|
||||||
targetSession = validSessions.find(s => s.source_app_id === data.current_session_id);
|
targetSession = validSessions.find(s => s.source_app_id === data.current_session_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Priority 3: Ultimate fallback to the first valid session available
|
// Priority 2: If the current session isn't available/valid, find any session that is currently playing
|
||||||
|
if (!targetSession || targetSession.playback_info.PlaybackStatus !== PlaybackStatus.PLAYING) {
|
||||||
|
const playingSession = validSessions.find(s => s.playback_info && s.playback_info.PlaybackStatus === PlaybackStatus.PLAYING);
|
||||||
|
if (playingSession) {
|
||||||
|
targetSession = playingSession;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Priority 3: Ultimate fallback to the first valid session available if nothing else matched
|
||||||
if (!targetSession && validSessions.length > 0) {
|
if (!targetSession && validSessions.length > 0) {
|
||||||
targetSession = validSessions[0];
|
targetSession = validSessions[0];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user