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
|
||||
|
||||
Reference in New Issue
Block a user