feat: Implement sound playback with credit validation in VLCPlayerService and update WebSocket handling
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user