refactor: Update player seek functionality to use consistent position field across schemas and services
All checks were successful
Backend CI / test (push) Successful in 4m5s
All checks were successful
Backend CI / test (push) Successful in 4m5s
This commit is contained in:
@@ -137,10 +137,10 @@ async def seek(
|
||||
"""Seek to specific position in current track."""
|
||||
try:
|
||||
player = get_player_service()
|
||||
await player.seek(request.position_ms)
|
||||
return MessageResponse(message=f"Seeked to position {request.position_ms}ms")
|
||||
await player.seek(request.position)
|
||||
return MessageResponse(message=f"Seeked to position {request.position}ms")
|
||||
except Exception as e:
|
||||
logger.exception("Error seeking to position %s", request.position_ms)
|
||||
logger.exception("Error seeking to position %s", request.position)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
detail="Failed to seek",
|
||||
|
||||
@@ -10,7 +10,7 @@ from app.services.player import PlayerMode
|
||||
class PlayerSeekRequest(BaseModel):
|
||||
"""Request model for seek operation."""
|
||||
|
||||
position_ms: int = Field(ge=0, description="Position in milliseconds")
|
||||
position: int = Field(ge=0, description="Position in milliseconds")
|
||||
|
||||
|
||||
class PlayerVolumeRequest(BaseModel):
|
||||
@@ -35,8 +35,8 @@ class PlayerStateResponse(BaseModel):
|
||||
playlist: dict[str, Any] | None = Field(
|
||||
None, description="Current playlist information"
|
||||
)
|
||||
position_ms: int = Field(description="Current position in milliseconds")
|
||||
duration_ms: int | None = Field(
|
||||
position: int = Field(description="Current position in milliseconds")
|
||||
duration: int | None = Field(
|
||||
None, description="Total duration in milliseconds",
|
||||
)
|
||||
volume: int = Field(description="Current volume (0-100)")
|
||||
|
||||
@@ -64,8 +64,8 @@ class PlayerState:
|
||||
"status": self.status.value,
|
||||
"mode": self.mode.value,
|
||||
"volume": self.volume,
|
||||
"position_ms": self.current_sound_position or 0,
|
||||
"duration_ms": self.current_sound_duration,
|
||||
"position": self.current_sound_position or 0,
|
||||
"duration": self.current_sound_duration,
|
||||
"index": self.current_sound_index,
|
||||
"current_sound": self._serialize_sound(self.current_sound),
|
||||
"playlist": {
|
||||
|
||||
Reference in New Issue
Block a user