tuanchris 1 ماه پیش
والد
کامیت
4f6db880da
2فایلهای تغییر یافته به همراه8 افزوده شده و 6 حذف شده
  1. 7 6
      static/js/base.js
  2. 1 0
      static/js/index.js

+ 7 - 6
static/js/base.js

@@ -189,6 +189,13 @@ function connectWebSocket() {
         try {
             const data = JSON.parse(event.data);
             if (data.type === 'status_update') {
+                // Always update global playback status (not throttled)
+                // This ensures play button always has current state
+                window.currentPlaybackStatus = {
+                    is_running: data.data.is_running || false,
+                    current_file: data.data.current_file || null
+                };
+
                 // Throttle UI updates for better Pi performance
                 const now = Date.now();
                 if (now - lastUIUpdate < UI_UPDATE_INTERVAL) {
@@ -196,12 +203,6 @@ function connectWebSocket() {
                 }
                 lastUIUpdate = now;
 
-                // Update global playback status
-                window.currentPlaybackStatus = {
-                    is_running: data.data.is_running || false,
-                    current_file: data.data.current_file || null
-                };
-
                 // Update modal status with the full data
                 syncModalControls(data.data);
                 

+ 1 - 0
static/js/index.js

@@ -1055,6 +1055,7 @@ function setupPreviewPanelEvents(pattern) {
             }
 
             // Check if a pattern is currently running and show stopping message
+            console.log('Play clicked, currentPlaybackStatus:', window.currentPlaybackStatus);
             if (window.currentPlaybackStatus?.is_running) {
                 showStatusMessage('Stopping current pattern...', 'info');
             }