feat: Update playlist loading method to use current playlist on startup
This commit is contained in:
@@ -69,8 +69,8 @@ class MusicPlayerService:
|
||||
|
||||
logger.info("VLC music player started successfully")
|
||||
|
||||
# Automatically load the main playlist
|
||||
self._load_main_playlist_on_startup()
|
||||
# Automatically load the current playlist
|
||||
self._load_current_playlist_on_startup()
|
||||
|
||||
self._start_sync_thread()
|
||||
return True
|
||||
@@ -636,28 +636,28 @@ class MusicPlayerService:
|
||||
logger.debug(f"Error syncing VLC state: {e}")
|
||||
|
||||
|
||||
def _load_main_playlist_on_startup(self):
|
||||
"""Load the main playlist automatically on startup."""
|
||||
def _load_current_playlist_on_startup(self):
|
||||
"""Load the current playlist automatically on startup."""
|
||||
try:
|
||||
if not self.app:
|
||||
logger.warning("No Flask app context available, skipping main playlist load")
|
||||
logger.warning("No Flask app context available, skipping current playlist load")
|
||||
return
|
||||
|
||||
with self.app.app_context():
|
||||
# Find the main playlist
|
||||
main_playlist = Playlist.find_main_playlist()
|
||||
# Find the current playlist
|
||||
current_playlist = Playlist.find_current_playlist()
|
||||
|
||||
if main_playlist:
|
||||
success = self.load_playlist(main_playlist.id)
|
||||
if current_playlist:
|
||||
success = self.load_playlist(current_playlist.id)
|
||||
if success:
|
||||
logger.info(f"Automatically loaded main playlist '{main_playlist.name}' with {len(self.playlist_files)} tracks")
|
||||
logger.info(f"Automatically loaded current playlist '{current_playlist.name}' with {len(self.playlist_files)} tracks")
|
||||
else:
|
||||
logger.warning("Failed to load main playlist on startup")
|
||||
logger.warning("Failed to load current playlist on startup")
|
||||
else:
|
||||
logger.info("No main playlist found to load on startup")
|
||||
logger.info("No current playlist found to load on startup")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error loading main playlist on startup: {e}")
|
||||
logger.error(f"Error loading current playlist on startup: {e}")
|
||||
|
||||
|
||||
# Global music player service instance
|
||||
|
||||
7
main.py
7
main.py
@@ -1,4 +1,5 @@
|
||||
import logging
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from app import create_app, socketio
|
||||
@@ -9,8 +10,8 @@ load_dotenv()
|
||||
# Configure logging
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
||||
datefmt='%H:%M:%S'
|
||||
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
||||
datefmt="%H:%M:%S",
|
||||
)
|
||||
|
||||
|
||||
@@ -18,7 +19,7 @@ def main() -> None:
|
||||
"""Run the Flask application with SocketIO."""
|
||||
app = create_app()
|
||||
socketio.run(
|
||||
app, debug=True, host="0.0.0.0", port=5000, allow_unsafe_werkzeug=True
|
||||
app, debug=True, host="127.0.0.1", port=5000, allow_unsafe_werkzeug=True
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user