remove redundant restAPI
playback is controlled by state machine
This commit is contained in:
@@ -28,7 +28,6 @@ public class JellyLmsController : ControllerBase
|
||||
{
|
||||
private readonly ILmsApiClient _lmsClient;
|
||||
private readonly LmsPlayerManager _playerManager;
|
||||
private readonly LmsSessionManager _sessionManager;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
/// <summary>
|
||||
@@ -36,17 +35,14 @@ public class JellyLmsController : ControllerBase
|
||||
/// </summary>
|
||||
/// <param name="lmsClient">The LMS API client.</param>
|
||||
/// <param name="playerManager">The player manager.</param>
|
||||
/// <param name="sessionManager">The session manager.</param>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
public JellyLmsController(
|
||||
ILmsApiClient lmsClient,
|
||||
LmsPlayerManager playerManager,
|
||||
LmsSessionManager sessionManager,
|
||||
ILibraryManager libraryManager)
|
||||
{
|
||||
_lmsClient = lmsClient;
|
||||
_playerManager = playerManager;
|
||||
_sessionManager = sessionManager;
|
||||
_libraryManager = libraryManager;
|
||||
}
|
||||
|
||||
@@ -192,110 +188,6 @@ public class JellyLmsController : ControllerBase
|
||||
return success ? Ok() : BadRequest("Failed to dissolve sync group");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all active playback sessions.
|
||||
/// </summary>
|
||||
/// <returns>List of active sessions.</returns>
|
||||
[HttpGet("Sessions")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public ActionResult<List<LmsPlaybackSession>> GetSessions()
|
||||
{
|
||||
return Ok(_sessionManager.GetActiveSessions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts playback of a Jellyfin item on LMS players.
|
||||
/// </summary>
|
||||
/// <param name="request">The playback request.</param>
|
||||
/// <returns>The created session.</returns>
|
||||
[HttpPost("Sessions/Play")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<ActionResult<LmsPlaybackSession>> StartPlayback([FromBody] StartPlaybackRequest request)
|
||||
{
|
||||
var session = await _sessionManager.StartPlaybackAsync(request.ItemId, request.PlayerMacs, request.UserId)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (session == null)
|
||||
{
|
||||
return BadRequest("Failed to start playback");
|
||||
}
|
||||
|
||||
return Ok(session);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pauses a playback session.
|
||||
/// </summary>
|
||||
/// <param name="sessionId">The session ID.</param>
|
||||
/// <returns>Success status.</returns>
|
||||
[HttpPost("Sessions/{sessionId}/Pause")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult> PauseSession(string sessionId)
|
||||
{
|
||||
var success = await _sessionManager.PauseSessionAsync(sessionId).ConfigureAwait(false);
|
||||
return success ? Ok() : NotFound();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resumes a paused playback session.
|
||||
/// </summary>
|
||||
/// <param name="sessionId">The session ID.</param>
|
||||
/// <returns>Success status.</returns>
|
||||
[HttpPost("Sessions/{sessionId}/Resume")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult> ResumeSession(string sessionId)
|
||||
{
|
||||
var success = await _sessionManager.ResumeSessionAsync(sessionId).ConfigureAwait(false);
|
||||
return success ? Ok() : NotFound();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops a playback session.
|
||||
/// </summary>
|
||||
/// <param name="sessionId">The session ID.</param>
|
||||
/// <returns>Success status.</returns>
|
||||
[HttpPost("Sessions/{sessionId}/Stop")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult> StopSession(string sessionId)
|
||||
{
|
||||
var success = await _sessionManager.StopSessionAsync(sessionId).ConfigureAwait(false);
|
||||
return success ? Ok() : NotFound();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Seeks to a position in the playback session.
|
||||
/// </summary>
|
||||
/// <param name="sessionId">The session ID.</param>
|
||||
/// <param name="request">The seek request.</param>
|
||||
/// <returns>Success status.</returns>
|
||||
[HttpPost("Sessions/{sessionId}/Seek")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult> SeekSession(string sessionId, [FromBody] SeekRequest request)
|
||||
{
|
||||
var success = await _sessionManager.SeekAsync(sessionId, request.PositionTicks).ConfigureAwait(false);
|
||||
return success ? Ok() : NotFound();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the volume for all players in a session.
|
||||
/// </summary>
|
||||
/// <param name="sessionId">The session ID.</param>
|
||||
/// <param name="request">The volume request.</param>
|
||||
/// <returns>Success status.</returns>
|
||||
[HttpPost("Sessions/{sessionId}/Volume")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult> SetSessionVolume(string sessionId, [FromBody] VolumeRequest request)
|
||||
{
|
||||
var success = await _sessionManager.SetVolumeAsync(sessionId, request.Volume).ConfigureAwait(false);
|
||||
return success ? Ok() : NotFound();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Discovers file paths used by Jellyfin's music libraries.
|
||||
/// Helps users configure path mappings for direct file access.
|
||||
@@ -407,37 +299,3 @@ public class CreateSyncGroupRequest
|
||||
[Required]
|
||||
public List<string> SlaveMacs { get; set; } = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request to start playback.
|
||||
/// </summary>
|
||||
public class StartPlaybackRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the Jellyfin item ID.
|
||||
/// </summary>
|
||||
[Required]
|
||||
public Guid ItemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the LMS player MAC addresses.
|
||||
/// </summary>
|
||||
[Required]
|
||||
public List<string> PlayerMacs { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional user ID.
|
||||
/// </summary>
|
||||
public Guid? UserId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request to seek to a position.
|
||||
/// </summary>
|
||||
public class SeekRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the position in ticks.
|
||||
/// </summary>
|
||||
public long PositionTicks { get; set; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user