refactor: Update PlayerState to improve serialization structure for current sound and playlist
Some checks failed
Backend CI / test (push) Failing after 4m2s
Some checks failed
Backend CI / test (push) Failing after 4m2s
This commit is contained in:
@@ -64,18 +64,19 @@ class PlayerState:
|
||||
"status": self.status.value,
|
||||
"mode": self.mode.value,
|
||||
"volume": self.volume,
|
||||
"current_sound_id": self.current_sound_id,
|
||||
"current_sound_index": self.current_sound_index,
|
||||
"current_sound_position": self.current_sound_position,
|
||||
"current_sound_duration": self.current_sound_duration,
|
||||
"position_ms": self.current_sound_position or 0,
|
||||
"duration_ms": self.current_sound_duration,
|
||||
"index": self.current_sound_index,
|
||||
"current_sound": self._serialize_sound(self.current_sound),
|
||||
"playlist_id": self.playlist_id,
|
||||
"playlist_name": self.playlist_name,
|
||||
"playlist_length": self.playlist_length,
|
||||
"playlist_duration": self.playlist_duration,
|
||||
"playlist_sounds": [
|
||||
self._serialize_sound(sound) for sound in self.playlist_sounds
|
||||
],
|
||||
"playlist": {
|
||||
"id": self.playlist_id,
|
||||
"name": self.playlist_name,
|
||||
"length": self.playlist_length,
|
||||
"duration": self.playlist_duration,
|
||||
"sounds": [
|
||||
self._serialize_sound(sound) for sound in self.playlist_sounds
|
||||
],
|
||||
} if self.playlist_id else None,
|
||||
}
|
||||
|
||||
def _serialize_sound(self, sound: Sound | None) -> dict[str, Any] | None:
|
||||
|
||||
Reference in New Issue
Block a user