2020-11-21 13:26:03 +00:00
|
|
|
using System;
|
2020-07-15 14:15:17 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
using System.Threading;
|
|
|
|
using Jellyfin.Api.Constants;
|
|
|
|
using Jellyfin.Api.Helpers;
|
|
|
|
using MediaBrowser.Controller.Net;
|
|
|
|
using MediaBrowser.Controller.Session;
|
|
|
|
using MediaBrowser.Controller.SyncPlay;
|
2020-11-14 22:40:01 +00:00
|
|
|
using MediaBrowser.Controller.SyncPlay.PlaybackRequests;
|
2020-07-15 14:15:17 +00:00
|
|
|
using MediaBrowser.Model.SyncPlay;
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
2020-07-22 08:20:51 +00:00
|
|
|
using Microsoft.AspNetCore.Http;
|
2020-07-15 14:15:17 +00:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
namespace Jellyfin.Api.Controllers
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// The sync play controller.
|
|
|
|
/// </summary>
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
public class SyncPlayController : BaseJellyfinApiController
|
|
|
|
{
|
|
|
|
private readonly ISessionManager _sessionManager;
|
|
|
|
private readonly IAuthorizationContext _authorizationContext;
|
|
|
|
private readonly ISyncPlayManager _syncPlayManager;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="SyncPlayController"/> class.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sessionManager">Instance of the <see cref="ISessionManager"/> interface.</param>
|
|
|
|
/// <param name="authorizationContext">Instance of the <see cref="IAuthorizationContext"/> interface.</param>
|
|
|
|
/// <param name="syncPlayManager">Instance of the <see cref="ISyncPlayManager"/> interface.</param>
|
|
|
|
public SyncPlayController(
|
|
|
|
ISessionManager sessionManager,
|
|
|
|
IAuthorizationContext authorizationContext,
|
|
|
|
ISyncPlayManager syncPlayManager)
|
|
|
|
{
|
|
|
|
_sessionManager = sessionManager;
|
|
|
|
_authorizationContext = authorizationContext;
|
|
|
|
_syncPlayManager = syncPlayManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Create a new SyncPlay group.
|
|
|
|
/// </summary>
|
2020-09-24 21:04:21 +00:00
|
|
|
/// <param name="groupName">The name of the new group.</param>
|
2020-07-22 08:20:51 +00:00
|
|
|
/// <response code="204">New group created.</response>
|
2020-07-15 14:15:17 +00:00
|
|
|
/// <returns>A <see cref="NoContentResult"/> indicating success.</returns>
|
|
|
|
[HttpPost("New")]
|
2020-07-22 08:20:51 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
2020-09-24 21:04:21 +00:00
|
|
|
public ActionResult SyncPlayCreateGroup(
|
|
|
|
[FromQuery, Required] string groupName)
|
2020-07-15 14:15:17 +00:00
|
|
|
{
|
|
|
|
var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request);
|
2020-11-15 16:03:27 +00:00
|
|
|
var newGroupRequest = new NewGroupRequest(groupName);
|
2020-09-24 21:04:21 +00:00
|
|
|
_syncPlayManager.NewGroup(currentSession, newGroupRequest, CancellationToken.None);
|
2020-07-15 14:15:17 +00:00
|
|
|
return NoContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Join an existing SyncPlay group.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="groupId">The sync play group id.</param>
|
2020-07-22 08:20:51 +00:00
|
|
|
/// <response code="204">Group join successful.</response>
|
2020-07-15 14:15:17 +00:00
|
|
|
/// <returns>A <see cref="NoContentResult"/> indicating success.</returns>
|
|
|
|
[HttpPost("Join")]
|
2020-07-22 08:20:51 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
2020-09-24 21:04:21 +00:00
|
|
|
public ActionResult SyncPlayJoinGroup(
|
|
|
|
[FromQuery, Required] Guid groupId)
|
2020-07-15 14:15:17 +00:00
|
|
|
{
|
|
|
|
var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request);
|
2020-11-15 16:03:27 +00:00
|
|
|
var joinRequest = new JoinGroupRequest(groupId);
|
2020-07-15 14:15:17 +00:00
|
|
|
_syncPlayManager.JoinGroup(currentSession, groupId, joinRequest, CancellationToken.None);
|
|
|
|
return NoContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Leave the joined SyncPlay group.
|
|
|
|
/// </summary>
|
2020-07-22 08:20:51 +00:00
|
|
|
/// <response code="204">Group leave successful.</response>
|
2020-07-15 14:15:17 +00:00
|
|
|
/// <returns>A <see cref="NoContentResult"/> indicating success.</returns>
|
|
|
|
[HttpPost("Leave")]
|
2020-07-22 08:20:51 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
2020-08-03 20:38:51 +00:00
|
|
|
public ActionResult SyncPlayLeaveGroup()
|
2020-07-15 14:15:17 +00:00
|
|
|
{
|
|
|
|
var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request);
|
|
|
|
_syncPlayManager.LeaveGroup(currentSession, CancellationToken.None);
|
|
|
|
return NoContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets all SyncPlay groups.
|
|
|
|
/// </summary>
|
2020-07-22 08:20:51 +00:00
|
|
|
/// <response code="200">Groups returned.</response>
|
2020-08-06 14:17:45 +00:00
|
|
|
/// <returns>An <see cref="IEnumerable{GroupInfoView}"/> containing the available SyncPlay groups.</returns>
|
2020-07-15 14:15:17 +00:00
|
|
|
[HttpGet("List")]
|
2020-07-22 08:20:51 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
2020-09-24 21:04:21 +00:00
|
|
|
public ActionResult<IEnumerable<GroupInfoDto>> SyncPlayGetGroups()
|
2020-07-15 14:15:17 +00:00
|
|
|
{
|
|
|
|
var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request);
|
2020-09-24 21:04:21 +00:00
|
|
|
return Ok(_syncPlayManager.ListGroups(currentSession));
|
2020-07-15 14:15:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Request play in SyncPlay group.
|
|
|
|
/// </summary>
|
2020-09-24 21:04:21 +00:00
|
|
|
/// <param name="playingQueue">The playing queue. Item ids in the playing queue, comma delimited.</param>
|
|
|
|
/// <param name="playingItemPosition">The playing item position from the queue.</param>
|
|
|
|
/// <param name="startPositionTicks">The start position ticks.</param>
|
2020-07-22 08:20:51 +00:00
|
|
|
/// <response code="204">Play request sent to all group members.</response>
|
2020-07-15 14:15:17 +00:00
|
|
|
/// <returns>A <see cref="NoContentResult"/> indicating success.</returns>
|
2020-07-22 14:49:52 +00:00
|
|
|
[HttpPost("Play")]
|
2020-07-22 08:20:51 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
2020-09-24 21:04:21 +00:00
|
|
|
public ActionResult SyncPlayPlay(
|
2020-11-14 22:40:01 +00:00
|
|
|
[FromQuery, Required] Guid[] playingQueue,
|
2020-09-24 21:04:21 +00:00
|
|
|
[FromQuery, Required] int playingItemPosition,
|
|
|
|
[FromQuery, Required] long startPositionTicks)
|
|
|
|
{
|
|
|
|
var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request);
|
2020-11-14 22:40:01 +00:00
|
|
|
var syncPlayRequest = new PlayGroupRequest(playingQueue, playingItemPosition, startPositionTicks);
|
2020-09-24 21:04:21 +00:00
|
|
|
_syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None);
|
|
|
|
return NoContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Request to change playlist item in SyncPlay group.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="playlistItemId">The playlist id of the item.</param>
|
|
|
|
/// <response code="204">Queue update request sent to all group members.</response>
|
|
|
|
/// <returns>A <see cref="NoContentResult"/> indicating success.</returns>
|
|
|
|
[HttpPost("SetPlaylistItem")]
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
public ActionResult SyncPlaySetPlaylistItem(
|
|
|
|
[FromQuery, Required] string playlistItemId)
|
|
|
|
{
|
|
|
|
var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request);
|
2020-11-14 22:40:01 +00:00
|
|
|
var syncPlayRequest = new SetPlaylistItemGroupRequest(playlistItemId);
|
2020-09-24 21:04:21 +00:00
|
|
|
_syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None);
|
|
|
|
return NoContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Request to remove items from the playlist in SyncPlay group.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="playlistItemIds">The playlist ids of the items to remove.</param>
|
|
|
|
/// <response code="204">Queue update request sent to all group members.</response>
|
|
|
|
/// <returns>A <see cref="NoContentResult"/> indicating success.</returns>
|
|
|
|
[HttpPost("RemoveFromPlaylist")]
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
public ActionResult SyncPlayRemoveFromPlaylist(
|
|
|
|
[FromQuery, Required] string[] playlistItemIds)
|
|
|
|
{
|
|
|
|
var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request);
|
2020-11-14 22:40:01 +00:00
|
|
|
var syncPlayRequest = new RemoveFromPlaylistGroupRequest(playlistItemIds);
|
2020-09-24 21:04:21 +00:00
|
|
|
_syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None);
|
|
|
|
return NoContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Request to move an item in the playlist in SyncPlay group.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="playlistItemId">The playlist id of the item to move.</param>
|
|
|
|
/// <param name="newIndex">The new position.</param>
|
|
|
|
/// <response code="204">Queue update request sent to all group members.</response>
|
|
|
|
/// <returns>A <see cref="NoContentResult"/> indicating success.</returns>
|
|
|
|
[HttpPost("MovePlaylistItem")]
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
public ActionResult SyncPlayMovePlaylistItem(
|
|
|
|
[FromQuery, Required] string playlistItemId,
|
|
|
|
[FromQuery, Required] int newIndex)
|
|
|
|
{
|
|
|
|
var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request);
|
2020-11-14 22:40:01 +00:00
|
|
|
var syncPlayRequest = new MovePlaylistItemGroupRequest(playlistItemId, newIndex);
|
2020-09-24 21:04:21 +00:00
|
|
|
_syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None);
|
|
|
|
return NoContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Request to queue items to the playlist of a SyncPlay group.
|
|
|
|
/// </summary>
|
2020-11-15 16:03:27 +00:00
|
|
|
/// <param name="itemIds">The items to add.</param>
|
2020-11-14 22:40:01 +00:00
|
|
|
/// <param name="mode">The mode in which to enqueue the items.</param>
|
2020-09-24 21:04:21 +00:00
|
|
|
/// <response code="204">Queue update request sent to all group members.</response>
|
|
|
|
/// <returns>A <see cref="NoContentResult"/> indicating success.</returns>
|
|
|
|
[HttpPost("Queue")]
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
public ActionResult SyncPlayQueue(
|
2020-11-15 16:03:27 +00:00
|
|
|
[FromQuery, Required] Guid[] itemIds,
|
2020-11-14 22:40:01 +00:00
|
|
|
[FromQuery, Required] GroupQueueMode mode)
|
2020-07-15 14:15:17 +00:00
|
|
|
{
|
|
|
|
var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request);
|
2020-11-15 16:03:27 +00:00
|
|
|
var syncPlayRequest = new QueueGroupRequest(itemIds, mode);
|
2020-07-15 14:15:17 +00:00
|
|
|
_syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None);
|
|
|
|
return NoContent();
|
|
|
|
}
|
|
|
|
|
2020-09-24 21:04:21 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Request unpause in SyncPlay group.
|
|
|
|
/// </summary>
|
|
|
|
/// <response code="204">Unpause request sent to all group members.</response>
|
|
|
|
/// <returns>A <see cref="NoContentResult"/> indicating success.</returns>
|
|
|
|
[HttpPost("Unpause")]
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
public ActionResult SyncPlayUnpause()
|
|
|
|
{
|
|
|
|
var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request);
|
|
|
|
var syncPlayRequest = new UnpauseGroupRequest();
|
|
|
|
_syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None);
|
|
|
|
return NoContent();
|
|
|
|
}
|
|
|
|
|
2020-07-15 14:15:17 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Request pause in SyncPlay group.
|
|
|
|
/// </summary>
|
2020-07-22 08:20:51 +00:00
|
|
|
/// <response code="204">Pause request sent to all group members.</response>
|
2020-07-15 14:15:17 +00:00
|
|
|
/// <returns>A <see cref="NoContentResult"/> indicating success.</returns>
|
2020-07-22 14:49:52 +00:00
|
|
|
[HttpPost("Pause")]
|
2020-07-22 08:20:51 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
2020-08-03 20:38:51 +00:00
|
|
|
public ActionResult SyncPlayPause()
|
2020-07-15 14:15:17 +00:00
|
|
|
{
|
|
|
|
var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request);
|
2020-09-24 21:04:21 +00:00
|
|
|
var syncPlayRequest = new PauseGroupRequest();
|
|
|
|
_syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None);
|
|
|
|
return NoContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Request stop in SyncPlay group.
|
|
|
|
/// </summary>
|
|
|
|
/// <response code="204">Stop request sent to all group members.</response>
|
|
|
|
/// <returns>A <see cref="NoContentResult"/> indicating success.</returns>
|
|
|
|
[HttpPost("Stop")]
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
public ActionResult SyncPlayStop()
|
|
|
|
{
|
|
|
|
var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request);
|
|
|
|
var syncPlayRequest = new StopGroupRequest();
|
2020-07-15 14:15:17 +00:00
|
|
|
_syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None);
|
|
|
|
return NoContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Request seek in SyncPlay group.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="positionTicks">The playback position in ticks.</param>
|
2020-07-22 08:20:51 +00:00
|
|
|
/// <response code="204">Seek request sent to all group members.</response>
|
2020-07-15 14:15:17 +00:00
|
|
|
/// <returns>A <see cref="NoContentResult"/> indicating success.</returns>
|
2020-07-22 14:49:52 +00:00
|
|
|
[HttpPost("Seek")]
|
2020-07-22 08:20:51 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
2020-09-24 21:04:21 +00:00
|
|
|
public ActionResult SyncPlaySeek(
|
|
|
|
[FromQuery, Required] long positionTicks)
|
2020-07-15 14:15:17 +00:00
|
|
|
{
|
|
|
|
var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request);
|
2020-11-14 22:40:01 +00:00
|
|
|
var syncPlayRequest = new SeekGroupRequest(positionTicks);
|
2020-07-15 14:15:17 +00:00
|
|
|
_syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None);
|
|
|
|
return NoContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Request group wait in SyncPlay group while buffering.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="when">When the request has been made by the client.</param>
|
|
|
|
/// <param name="positionTicks">The playback position in ticks.</param>
|
2020-09-24 21:04:21 +00:00
|
|
|
/// <param name="isPlaying">Whether the client's playback is playing or not.</param>
|
|
|
|
/// <param name="playlistItemId">The playlist item id.</param>
|
2020-07-15 14:15:17 +00:00
|
|
|
/// <param name="bufferingDone">Whether the buffering is done.</param>
|
2020-07-22 08:20:51 +00:00
|
|
|
/// <response code="204">Buffering request sent to all group members.</response>
|
2020-07-15 14:15:17 +00:00
|
|
|
/// <returns>A <see cref="NoContentResult"/> indicating success.</returns>
|
2020-07-22 14:49:52 +00:00
|
|
|
[HttpPost("Buffering")]
|
2020-07-22 08:20:51 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
2020-09-24 21:04:21 +00:00
|
|
|
public ActionResult SyncPlayBuffering(
|
|
|
|
[FromQuery, Required] DateTime when,
|
|
|
|
[FromQuery, Required] long positionTicks,
|
|
|
|
[FromQuery, Required] bool isPlaying,
|
|
|
|
[FromQuery, Required] string playlistItemId,
|
|
|
|
[FromQuery, Required] bool bufferingDone)
|
2020-07-15 14:15:17 +00:00
|
|
|
{
|
|
|
|
var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request);
|
2020-11-13 14:13:32 +00:00
|
|
|
IGroupPlaybackRequest syncPlayRequest;
|
2020-09-24 21:04:21 +00:00
|
|
|
if (!bufferingDone)
|
2020-07-15 14:15:17 +00:00
|
|
|
{
|
2020-11-14 22:40:01 +00:00
|
|
|
syncPlayRequest = new BufferGroupRequest(when, positionTicks, isPlaying, playlistItemId);
|
2020-09-24 21:04:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-14 22:40:01 +00:00
|
|
|
syncPlayRequest = new ReadyGroupRequest(when, positionTicks, isPlaying, playlistItemId);
|
2020-09-24 21:04:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None);
|
|
|
|
return NoContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Request SyncPlay group to ignore member during group-wait.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="ignoreWait">Whether to ignore the member.</param>
|
|
|
|
/// <response code="204">Member state updated.</response>
|
|
|
|
/// <returns>A <see cref="NoContentResult"/> indicating success.</returns>
|
|
|
|
[HttpPost("SetIgnoreWait")]
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
public ActionResult SyncPlaySetIgnoreWait(
|
|
|
|
[FromQuery, Required] bool ignoreWait)
|
|
|
|
{
|
|
|
|
var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request);
|
2020-11-14 22:40:01 +00:00
|
|
|
var syncPlayRequest = new IgnoreWaitGroupRequest(ignoreWait);
|
2020-09-24 21:04:21 +00:00
|
|
|
_syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None);
|
|
|
|
return NoContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Request next track in SyncPlay group.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="playlistItemId">The playing item id.</param>
|
|
|
|
/// <response code="204">Next track request sent to all group members.</response>
|
|
|
|
/// <returns>A <see cref="NoContentResult"/> indicating success.</returns>
|
|
|
|
[HttpPost("NextTrack")]
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
public ActionResult SyncPlayNextTrack(
|
|
|
|
[FromQuery, Required] string playlistItemId)
|
|
|
|
{
|
|
|
|
var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request);
|
2020-11-14 22:40:01 +00:00
|
|
|
var syncPlayRequest = new NextTrackGroupRequest(playlistItemId);
|
2020-09-24 21:04:21 +00:00
|
|
|
_syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None);
|
|
|
|
return NoContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Request previous track in SyncPlay group.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="playlistItemId">The playing item id.</param>
|
|
|
|
/// <response code="204">Previous track request sent to all group members.</response>
|
|
|
|
/// <returns>A <see cref="NoContentResult"/> indicating success.</returns>
|
|
|
|
[HttpPost("PreviousTrack")]
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
public ActionResult SyncPlayPreviousTrack(
|
|
|
|
[FromQuery, Required] string playlistItemId)
|
|
|
|
{
|
|
|
|
var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request);
|
2020-11-14 22:40:01 +00:00
|
|
|
var syncPlayRequest = new PreviousTrackGroupRequest(playlistItemId);
|
2020-09-24 21:04:21 +00:00
|
|
|
_syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None);
|
|
|
|
return NoContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Request to set repeat mode in SyncPlay group.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="mode">The repeat mode.</param>
|
|
|
|
/// <response code="204">Play queue update sent to all group members.</response>
|
|
|
|
/// <returns>A <see cref="NoContentResult"/> indicating success.</returns>
|
|
|
|
[HttpPost("SetRepeatMode")]
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
public ActionResult SyncPlaySetRepeatMode(
|
2020-11-14 22:40:01 +00:00
|
|
|
[FromQuery, Required] GroupRepeatMode mode)
|
2020-09-24 21:04:21 +00:00
|
|
|
{
|
|
|
|
var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request);
|
2020-11-14 22:40:01 +00:00
|
|
|
var syncPlayRequest = new SetRepeatModeGroupRequest(mode);
|
2020-09-24 21:04:21 +00:00
|
|
|
_syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None);
|
|
|
|
return NoContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Request to set shuffle mode in SyncPlay group.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="mode">The shuffle mode.</param>
|
|
|
|
/// <response code="204">Play queue update sent to all group members.</response>
|
|
|
|
/// <returns>A <see cref="NoContentResult"/> indicating success.</returns>
|
|
|
|
[HttpPost("SetShuffleMode")]
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
public ActionResult SyncPlaySetShuffleMode(
|
2020-11-14 22:40:01 +00:00
|
|
|
[FromQuery, Required] GroupShuffleMode mode)
|
2020-09-24 21:04:21 +00:00
|
|
|
{
|
|
|
|
var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request);
|
2020-11-14 22:40:01 +00:00
|
|
|
var syncPlayRequest = new SetShuffleModeGroupRequest(mode);
|
2020-07-15 14:15:17 +00:00
|
|
|
_syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None);
|
|
|
|
return NoContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Update session ping.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="ping">The ping.</param>
|
2020-07-22 08:20:51 +00:00
|
|
|
/// <response code="204">Ping updated.</response>
|
2020-07-15 14:15:17 +00:00
|
|
|
/// <returns>A <see cref="NoContentResult"/> indicating success.</returns>
|
2020-07-22 14:53:56 +00:00
|
|
|
[HttpPost("Ping")]
|
2020-07-22 08:20:51 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
2020-09-24 21:04:21 +00:00
|
|
|
public ActionResult SyncPlayPing(
|
|
|
|
[FromQuery, Required] double ping)
|
2020-07-15 14:15:17 +00:00
|
|
|
{
|
|
|
|
var currentSession = RequestHelpers.GetSession(_sessionManager, _authorizationContext, Request);
|
2020-11-14 22:40:01 +00:00
|
|
|
var syncPlayRequest = new PingGroupRequest(Convert.ToInt64(ping));
|
2020-07-15 14:15:17 +00:00
|
|
|
_syncPlayManager.HandleRequest(currentSession, syncPlayRequest, CancellationToken.None);
|
|
|
|
return NoContent();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|