From 9465276f78487c875e43552ac8f55cb87cf769d1 Mon Sep 17 00:00:00 2001 From: Charles Madere Date: Wed, 5 Feb 2025 01:44:25 +0900 Subject: [PATCH] small python cleanup --- .../audioPlayerSoundPlayerManager.py | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/soundPlayerManager/audioPlayer/audioPlayerSoundPlayerManager.py b/src/soundPlayerManager/audioPlayer/audioPlayerSoundPlayerManager.py index b480f9bc..0ddf70f2 100644 --- a/src/soundPlayerManager/audioPlayer/audioPlayerSoundPlayerManager.py +++ b/src/soundPlayerManager/audioPlayer/audioPlayerSoundPlayerManager.py @@ -267,26 +267,26 @@ async def __progressThroughPlaylist(self, playlist: SoundPlayerPlaylist): try: while self.__isLoadingOrPlaying and not playErrorOccurred and (currentPlaylistIndex < len(playlist.playlistFiles) or mediaPlayer.isPlaying): if mediaPlayer.isPlaying: - pass + continue + + if currentPlaylistIndex < 0: + currentPlaylistIndex = 0 else: - if currentPlaylistIndex < 0: - currentPlaylistIndex = 0 - else: - currentPlaylistIndex += 1 + currentPlaylistIndex += 1 - if currentPlaylistIndex < len(playlist.playlistFiles): - currentFile = playlist.playlistFiles[currentPlaylistIndex] - currentVolume = currentFile.volume + if currentPlaylistIndex < len(playlist.playlistFiles): + currentFile = playlist.playlistFiles[currentPlaylistIndex] + currentVolume = currentFile.volume - if not utils.isValidInt(currentVolume): - currentVolume = baseVolume + if not utils.isValidInt(currentVolume): + currentVolume = baseVolume - await mediaPlayer.setMedia(currentFile.filePath) - await mediaPlayer.setVolume(currentVolume) + await mediaPlayer.setMedia(currentFile.filePath) + await mediaPlayer.setVolume(currentVolume) - if not await mediaPlayer.play(): - self.__timber.log('AudioPlayerSoundPlayerManager', f'Received bad playback result when attempting to play media element at playlist index ({currentPlaylistIndex=}) ({currentFile=}) ({currentVolume=}) ({playlist=}) ({baseVolume=}) ({mediaPlayer=})') - playErrorOccurred = True + if not await mediaPlayer.play(): + self.__timber.log('AudioPlayerSoundPlayerManager', f'Received bad playback result when attempting to play media element at playlist index ({currentPlaylistIndex=}) ({currentFile=}) ({currentVolume=}) ({playlist=}) ({baseVolume=}) ({mediaPlayer=})') + playErrorOccurred = True await asyncio.sleep(self.__playbackLoopSleepTimeSeconds) except Exception as e: