本文整理汇总了C#中IApiClient.GetPlaybackInfo方法的典型用法代码示例。如果您正苦于以下问题:C# IApiClient.GetPlaybackInfo方法的具体用法?C# IApiClient.GetPlaybackInfo怎么用?C# IApiClient.GetPlaybackInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IApiClient
的用法示例。
在下文中一共展示了IApiClient.GetPlaybackInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetVideoStreamInfo
/// <summary>
/// Gets the video stream information.
/// </summary>
/// <param name="serverId">The server identifier.</param>
/// <param name="options">The options.</param>
/// <param name="isOffline">if set to <c>true</c> [is offline].</param>
/// <param name="apiClient">The API client.</param>
/// <returns>Task<StreamInfo>.</returns>
public async Task<StreamInfo> GetVideoStreamInfo(string serverId, VideoOptions options, bool isOffline, IApiClient apiClient)
{
PlaybackInfoResponse playbackInfo = null;
string playSessionId = null;
if (!isOffline)
{
playbackInfo = await apiClient.GetPlaybackInfo(new PlaybackInfoRequest
{
Id = options.ItemId,
UserId = apiClient.CurrentUserId,
MaxStreamingBitrate = options.MaxBitrate,
MediaSourceId = options.MediaSourceId,
AudioStreamIndex = options.AudioStreamIndex,
SubtitleStreamIndex = options.SubtitleStreamIndex
}).ConfigureAwait(false);
if (playbackInfo.ErrorCode.HasValue)
{
throw new PlaybackException { ErrorCode = playbackInfo.ErrorCode.Value };
}
options.MediaSources = playbackInfo.MediaSources;
playSessionId = playbackInfo.PlaySessionId;
}
var streamInfo = await GetVideoStreamInfoInternal(serverId, options).ConfigureAwait(false);
if (!isOffline)
{
var liveMediaSource = await GetLiveStreamInfo(playSessionId, streamInfo.MediaSource, options, apiClient).ConfigureAwait(false);
if (liveMediaSource != null)
{
options.MediaSources = new List<MediaSourceInfo> { liveMediaSource };
streamInfo = GetStreamBuilder().BuildVideoItem(options);
EnsureSuccess(streamInfo);
}
}
if (playbackInfo != null)
{
streamInfo.AllMediaSources = playbackInfo.MediaSources.ToList();
streamInfo.PlaySessionId = playbackInfo.PlaySessionId;
}
return streamInfo;
}
示例2: GetAudioStreamInfo
/// <summary>
/// Gets the audio stream information.
/// </summary>
/// <param name="serverId">The server identifier.</param>
/// <param name="options">The options.</param>
/// <param name="isOffline">if set to <c>true</c> [is offline].</param>
/// <param name="apiClient">The API client.</param>
/// <returns>Task<StreamInfo>.</returns>
public async Task<StreamInfo> GetAudioStreamInfo(string serverId, AudioOptions options, bool isOffline, IApiClient apiClient)
{
var streamBuilder = GetStreamBuilder();
var localItem = await _localAssetManager.GetLocalItem(serverId, options.ItemId);
if (localItem != null)
{
var localMediaSource = localItem.Item.MediaSources[0];
// Use the local media source, unless a specific server media source was requested
if (string.IsNullOrWhiteSpace(options.MediaSourceId) ||
string.Equals(localMediaSource.Id, options.MediaSourceId,
StringComparison.OrdinalIgnoreCase))
{
// Finally, check to make sure the local file is actually available at this time
var fileExists = await _localAssetManager.FileExists(localMediaSource.Path).ConfigureAwait(false);
if (fileExists)
{
options.MediaSources = localItem.Item.MediaSources;
var result = streamBuilder.BuildAudioItem(options);
if (result == null)
{
_logger.Warn("LocalItem returned no compatible streams. Will dummy up a StreamInfo to force it to direct play.");
var mediaSource = localItem.Item.MediaSources.First();
result = GetForcedDirectPlayStreamInfo(DlnaProfileType.Audio, options, mediaSource);
}
result.PlayMethod = PlayMethod.DirectPlay;
return result;
}
}
}
PlaybackInfoResponse playbackInfo = null;
string playSessionId = null;
if (!isOffline)
{
playbackInfo = await apiClient.GetPlaybackInfo(new PlaybackInfoRequest
{
Id = options.ItemId,
UserId = apiClient.CurrentUserId,
MaxStreamingBitrate = options.MaxBitrate,
MediaSourceId = options.MediaSourceId
}).ConfigureAwait(false);
if (playbackInfo.ErrorCode.HasValue)
{
throw new PlaybackException { ErrorCode = playbackInfo.ErrorCode.Value };
}
options.MediaSources = playbackInfo.MediaSources;
playSessionId = playbackInfo.PlaySessionId;
}
var streamInfo = streamBuilder.BuildAudioItem(options);
EnsureSuccess(streamInfo);
if (!isOffline)
{
var liveMediaSource = await GetLiveStreamInfo(playSessionId, streamInfo.MediaSource, options, apiClient).ConfigureAwait(false);
if (liveMediaSource != null)
{
options.MediaSources = new List<MediaSourceInfo> { liveMediaSource };
streamInfo = GetStreamBuilder().BuildAudioItem(options);
EnsureSuccess(streamInfo);
}
}
if (playbackInfo != null)
{
streamInfo.AllMediaSources = playbackInfo.MediaSources.ToList();
streamInfo.PlaySessionId = playbackInfo.PlaySessionId;
}
return streamInfo;
}