feat: Implement sound playback with credit validation in VLCPlayerService and update WebSocket handling
Some checks failed
Backend CI / lint (push) Failing after 5m0s
Backend CI / test (push) Failing after 2m0s

This commit is contained in:
JSC
2025-08-19 22:16:48 +02:00
parent 560ccd3f7e
commit a82acfae50
3 changed files with 104 additions and 75 deletions

View File

@@ -111,20 +111,28 @@ class SocketManager:
sound_id = data.get("sound_id")
if not sound_id:
logger.warning(
"Play sound request missing sound_id from user %s", user_id,
"Play sound request missing sound_id from user %s",
user_id,
)
return
try:
# Import here to avoid circular imports
from app.api.v1.sounds import play_sound_internal
from app.services.vlc_player import get_vlc_player_service
from app.core.database import get_session_factory
# Call the internal play sound function
await play_sound_internal(int(sound_id), user_id)
# Get VLC player service with database factory
vlc_player = get_vlc_player_service(get_session_factory())
# Call the service method
await vlc_player.play_sound_with_credits(int(sound_id), int(user_id))
logger.info("User %s played sound %s via WebSocket", user_id, sound_id)
except Exception as e:
logger.exception(
"Error playing sound %s for user %s: %s", sound_id, user_id, e,
"Error playing sound %s for user %s: %s",
sound_id,
user_id,
e,
)
# Emit error back to user
await self.sio.emit(