2015-03-07 22:43:53 +00:00
|
|
|
|
using MediaBrowser.Controller.Library;
|
2014-11-19 02:45:12 +00:00
|
|
|
|
using MediaBrowser.Controller.Net;
|
|
|
|
|
using MediaBrowser.Model.MediaInfo;
|
|
|
|
|
using ServiceStack;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Api.Playback
|
|
|
|
|
{
|
2015-03-03 07:03:17 +00:00
|
|
|
|
[Route("/Items/{Id}/PlaybackInfo", "GET", Summary = "Gets live playback media info for an item")]
|
2014-11-19 02:45:12 +00:00
|
|
|
|
public class GetLiveMediaInfo : IReturn<LiveMediaInfoResult>
|
|
|
|
|
{
|
|
|
|
|
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
|
|
|
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
|
|
|
|
public string UserId { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-07 22:43:53 +00:00
|
|
|
|
[Route("/Items/{Id}/PlaybackInfo", "GET", Summary = "Gets live playback media info for an item")]
|
|
|
|
|
public class GetPlaybackInfo : IReturn<LiveMediaInfoResult>
|
|
|
|
|
{
|
|
|
|
|
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
|
|
|
|
|
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
|
|
|
|
public string UserId { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-19 02:45:12 +00:00
|
|
|
|
[Authenticated]
|
|
|
|
|
public class MediaInfoService : BaseApiService
|
|
|
|
|
{
|
2015-03-07 22:43:53 +00:00
|
|
|
|
private readonly IMediaSourceManager _mediaSourceManager;
|
2014-11-19 02:45:12 +00:00
|
|
|
|
|
2015-03-07 22:43:53 +00:00
|
|
|
|
public MediaInfoService(IMediaSourceManager mediaSourceManager)
|
2014-11-19 02:45:12 +00:00
|
|
|
|
{
|
2015-03-07 22:43:53 +00:00
|
|
|
|
_mediaSourceManager = mediaSourceManager;
|
2014-11-19 02:45:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-07 22:43:53 +00:00
|
|
|
|
public async Task<object> Get(GetPlaybackInfo request)
|
2014-11-19 02:45:12 +00:00
|
|
|
|
{
|
2015-03-12 03:37:25 +00:00
|
|
|
|
var mediaSources = await _mediaSourceManager.GetPlayackMediaSources(request.Id, request.UserId, true, CancellationToken.None).ConfigureAwait(false);
|
2014-11-19 02:45:12 +00:00
|
|
|
|
|
2015-03-07 22:43:53 +00:00
|
|
|
|
return ToOptimizedResult(new LiveMediaInfoResult
|
2014-11-19 02:45:12 +00:00
|
|
|
|
{
|
2015-03-07 22:43:53 +00:00
|
|
|
|
MediaSources = mediaSources.ToList()
|
|
|
|
|
});
|
|
|
|
|
}
|
2014-11-26 04:12:29 +00:00
|
|
|
|
|
2015-03-07 22:43:53 +00:00
|
|
|
|
public async Task<object> Get(GetLiveMediaInfo request)
|
|
|
|
|
{
|
2015-03-12 03:37:25 +00:00
|
|
|
|
var mediaSources = await _mediaSourceManager.GetPlayackMediaSources(request.Id, request.UserId, true, CancellationToken.None).ConfigureAwait(false);
|
2014-11-19 02:45:12 +00:00
|
|
|
|
|
|
|
|
|
return ToOptimizedResult(new LiveMediaInfoResult
|
|
|
|
|
{
|
|
|
|
|
MediaSources = mediaSources.ToList()
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|