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")
|
logger.info("VLC music player started successfully")
|
||||||
|
|
||||||
# Automatically load the main playlist
|
# Automatically load the current playlist
|
||||||
self._load_main_playlist_on_startup()
|
self._load_current_playlist_on_startup()
|
||||||
|
|
||||||
self._start_sync_thread()
|
self._start_sync_thread()
|
||||||
return True
|
return True
|
||||||
@@ -636,28 +636,28 @@ class MusicPlayerService:
|
|||||||
logger.debug(f"Error syncing VLC state: {e}")
|
logger.debug(f"Error syncing VLC state: {e}")
|
||||||
|
|
||||||
|
|
||||||
def _load_main_playlist_on_startup(self):
|
def _load_current_playlist_on_startup(self):
|
||||||
"""Load the main playlist automatically on startup."""
|
"""Load the current playlist automatically on startup."""
|
||||||
try:
|
try:
|
||||||
if not self.app:
|
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
|
return
|
||||||
|
|
||||||
with self.app.app_context():
|
with self.app.app_context():
|
||||||
# Find the main playlist
|
# Find the current playlist
|
||||||
main_playlist = Playlist.find_main_playlist()
|
current_playlist = Playlist.find_current_playlist()
|
||||||
|
|
||||||
if main_playlist:
|
if current_playlist:
|
||||||
success = self.load_playlist(main_playlist.id)
|
success = self.load_playlist(current_playlist.id)
|
||||||
if success:
|
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:
|
else:
|
||||||
logger.warning("Failed to load main playlist on startup")
|
logger.warning("Failed to load current playlist on startup")
|
||||||
else:
|
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:
|
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
|
# Global music player service instance
|
||||||
|
|||||||
7
main.py
7
main.py
@@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
from app import create_app, socketio
|
from app import create_app, socketio
|
||||||
@@ -9,8 +10,8 @@ load_dotenv()
|
|||||||
# Configure logging
|
# Configure logging
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=logging.INFO,
|
level=logging.INFO,
|
||||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
||||||
datefmt='%H:%M:%S'
|
datefmt="%H:%M:%S",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ def main() -> None:
|
|||||||
"""Run the Flask application with SocketIO."""
|
"""Run the Flask application with SocketIO."""
|
||||||
app = create_app()
|
app = create_app()
|
||||||
socketio.run(
|
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