|
|
|
@ -1,7 +1,10 @@
|
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
|
using MediaBrowser.Controller.Net;
|
|
|
|
|
using MediaBrowser.Model.Dlna;
|
|
|
|
|
using MediaBrowser.Model.Dto;
|
|
|
|
|
using MediaBrowser.Model.MediaInfo;
|
|
|
|
|
using ServiceStack;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
@ -38,24 +41,34 @@ namespace MediaBrowser.Api.Playback
|
|
|
|
|
_mediaSourceManager = mediaSourceManager;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<object> Get(GetPlaybackInfo request)
|
|
|
|
|
public Task<object> Get(GetPlaybackInfo request)
|
|
|
|
|
{
|
|
|
|
|
var mediaSources = await _mediaSourceManager.GetPlayackMediaSources(request.Id, request.UserId, true, CancellationToken.None).ConfigureAwait(false);
|
|
|
|
|
return GetPlaybackInfo(request.Id, request.UserId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ToOptimizedResult(new LiveMediaInfoResult
|
|
|
|
|
{
|
|
|
|
|
MediaSources = mediaSources.ToList()
|
|
|
|
|
});
|
|
|
|
|
public Task<object> Get(GetLiveMediaInfo request)
|
|
|
|
|
{
|
|
|
|
|
return GetPlaybackInfo(request.Id, request.UserId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<object> Get(GetLiveMediaInfo request)
|
|
|
|
|
private async Task<object> GetPlaybackInfo(string id, string userId)
|
|
|
|
|
{
|
|
|
|
|
var mediaSources = await _mediaSourceManager.GetPlayackMediaSources(request.Id, request.UserId, true, CancellationToken.None).ConfigureAwait(false);
|
|
|
|
|
IEnumerable<MediaSourceInfo> mediaSources;
|
|
|
|
|
var result = new LiveMediaInfoResult();
|
|
|
|
|
|
|
|
|
|
return ToOptimizedResult(new LiveMediaInfoResult
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
MediaSources = mediaSources.ToList()
|
|
|
|
|
});
|
|
|
|
|
mediaSources = await _mediaSourceManager.GetPlayackMediaSources(id, userId, true, CancellationToken.None).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
catch (PlaybackException ex)
|
|
|
|
|
{
|
|
|
|
|
mediaSources = new List<MediaSourceInfo>();
|
|
|
|
|
result.ErrorCode = ex.ErrorCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.MediaSources = mediaSources.ToList();
|
|
|
|
|
|
|
|
|
|
return ToOptimizedResult(result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|