control remote players with now playing bar
This commit is contained in:
parent
3817ff36b0
commit
b6ca79b73f
|
@ -97,6 +97,22 @@ namespace MediaBrowser.Controller.Session
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
Task SendSessionEndedNotification(SessionInfoDto sessionInfo, CancellationToken cancellationToken);
|
Task SendSessionEndedNotification(SessionInfoDto sessionInfo, CancellationToken cancellationToken);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends the playback start notification.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sessionInfo">The session information.</param>
|
||||||
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
|
/// <returns>Task.</returns>
|
||||||
|
Task SendPlaybackStartNotification(SessionInfoDto sessionInfo, CancellationToken cancellationToken);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends the playback start notification.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sessionInfo">The session information.</param>
|
||||||
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
|
/// <returns>Task.</returns>
|
||||||
|
Task SendPlaybackStoppedNotification(SessionInfoDto sessionInfo, CancellationToken cancellationToken);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends the server restart notification.
|
/// Sends the server restart notification.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -331,6 +331,16 @@ namespace MediaBrowser.Dlna.PlayTo
|
||||||
return Task.FromResult(true);
|
return Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task SendPlaybackStartNotification(SessionInfoDto sessionInfo, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
return Task.FromResult(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task SendPlaybackStoppedNotification(SessionInfoDto sessionInfo, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
return Task.FromResult(true);
|
||||||
|
}
|
||||||
|
|
||||||
public Task SendServerShutdownNotification(CancellationToken cancellationToken)
|
public Task SendServerShutdownNotification(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
return Task.FromResult(true);
|
return Task.FromResult(true);
|
||||||
|
|
|
@ -46,6 +46,12 @@ namespace MediaBrowser.Model.Entities
|
||||||
/// <value>The primary image tag.</value>
|
/// <value>The primary image tag.</value>
|
||||||
public Guid? PrimaryImageTag { get; set; }
|
public Guid? PrimaryImageTag { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the primary image item identifier.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The primary image item identifier.</value>
|
||||||
|
public string PrimaryImageItemId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the thumb image tag.
|
/// Gets or sets the thumb image tag.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -46,6 +46,7 @@ namespace MediaBrowser.Model.Session
|
||||||
ToggleMute = 21,
|
ToggleMute = 21,
|
||||||
SetVolume = 22,
|
SetVolume = 22,
|
||||||
SetAudioStreamIndex = 23,
|
SetAudioStreamIndex = 23,
|
||||||
SetSubtitleStreamIndex = 24
|
SetSubtitleStreamIndex = 24,
|
||||||
|
ToggleFullscreen = 25
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,10 +31,6 @@ namespace MediaBrowser.Model.Session
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Seek,
|
Seek,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The fullscreen
|
|
||||||
/// </summary>
|
|
||||||
Fullscreen,
|
|
||||||
/// <summary>
|
|
||||||
/// The rewind
|
/// The rewind
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Rewind,
|
Rewind,
|
||||||
|
|
|
@ -46,6 +46,16 @@ namespace MediaBrowser.Server.Implementations.Roku
|
||||||
return Task.FromResult(true);
|
return Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task SendPlaybackStartNotification(SessionInfoDto sessionInfo, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
return Task.FromResult(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task SendPlaybackStoppedNotification(SessionInfoDto sessionInfo, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
return Task.FromResult(true);
|
||||||
|
}
|
||||||
|
|
||||||
public Task SendMessageCommand(MessageCommand command, CancellationToken cancellationToken)
|
public Task SendMessageCommand(MessageCommand command, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
return SendCommand(new WebSocketMessage<MessageCommand>
|
return SendCommand(new WebSocketMessage<MessageCommand>
|
||||||
|
|
|
@ -444,6 +444,8 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||||
MediaSourceId = info.MediaSourceId
|
MediaSourceId = info.MediaSourceId
|
||||||
|
|
||||||
}, _logger);
|
}, _logger);
|
||||||
|
|
||||||
|
await SendPlaybackStartNotification(session, CancellationToken.None).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -583,6 +585,8 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||||
MediaSourceId = mediaSourceId
|
MediaSourceId = mediaSourceId
|
||||||
|
|
||||||
}, _logger);
|
}, _logger);
|
||||||
|
|
||||||
|
await SendPlaybackStoppedNotification(session, CancellationToken.None).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetMediaSourceId(BaseItem item, string reportedMediaSourceId)
|
private string GetMediaSourceId(BaseItem item, string reportedMediaSourceId)
|
||||||
|
@ -972,7 +976,6 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||||
return Task.WhenAll(tasks);
|
return Task.WhenAll(tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Task SendSessionEndedNotification(SessionInfo sessionInfo, CancellationToken cancellationToken)
|
public Task SendSessionEndedNotification(SessionInfo sessionInfo, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var sessions = Sessions.Where(i => i.IsActive && i.SessionController != null).ToList();
|
var sessions = Sessions.Where(i => i.IsActive && i.SessionController != null).ToList();
|
||||||
|
@ -994,6 +997,48 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||||
return Task.WhenAll(tasks);
|
return Task.WhenAll(tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task SendPlaybackStartNotification(SessionInfo sessionInfo, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var sessions = Sessions.Where(i => i.IsActive && i.SessionController != null).ToList();
|
||||||
|
var dto = GetSessionInfoDto(sessionInfo);
|
||||||
|
|
||||||
|
var tasks = sessions.Select(session => Task.Run(async () =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await session.SessionController.SendPlaybackStartNotification(dto, cancellationToken).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.ErrorException("Error in SendPlaybackStartNotification.", ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
}, cancellationToken));
|
||||||
|
|
||||||
|
return Task.WhenAll(tasks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task SendPlaybackStoppedNotification(SessionInfo sessionInfo, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var sessions = Sessions.Where(i => i.IsActive && i.SessionController != null).ToList();
|
||||||
|
var dto = GetSessionInfoDto(sessionInfo);
|
||||||
|
|
||||||
|
var tasks = sessions.Select(session => Task.Run(async () =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await session.SessionController.SendPlaybackStoppedNotification(dto, cancellationToken).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.ErrorException("Error in SendPlaybackStoppedNotification.", ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
}, cancellationToken));
|
||||||
|
|
||||||
|
return Task.WhenAll(tasks);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds the additional user.
|
/// Adds the additional user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1163,6 +1208,11 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||||
|
|
||||||
info.PrimaryImageTag = GetImageCacheTag(item, ImageType.Primary);
|
info.PrimaryImageTag = GetImageCacheTag(item, ImageType.Primary);
|
||||||
|
|
||||||
|
if (info.PrimaryImageTag.HasValue)
|
||||||
|
{
|
||||||
|
info.PrimaryImageItemId = GetDtoId(item);
|
||||||
|
}
|
||||||
|
|
||||||
var backropItem = item.HasImage(ImageType.Backdrop) ? item : null;
|
var backropItem = item.HasImage(ImageType.Backdrop) ? item : null;
|
||||||
|
|
||||||
var thumbItem = item.HasImage(ImageType.Thumb) ? item : null;
|
var thumbItem = item.HasImage(ImageType.Thumb) ? item : null;
|
||||||
|
|
|
@ -210,5 +210,29 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||||
|
|
||||||
}, cancellationToken);
|
}, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task SendPlaybackStartNotification(SessionInfoDto sessionInfo, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var socket = GetActiveSocket();
|
||||||
|
|
||||||
|
return socket.SendAsync(new WebSocketMessage<SessionInfoDto>
|
||||||
|
{
|
||||||
|
MessageType = "PlaybackStart",
|
||||||
|
Data = sessionInfo
|
||||||
|
|
||||||
|
}, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task SendPlaybackStoppedNotification(SessionInfoDto sessionInfo, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var socket = GetActiveSocket();
|
||||||
|
|
||||||
|
return socket.SendAsync(new WebSocketMessage<SessionInfoDto>
|
||||||
|
{
|
||||||
|
MessageType = "PlaybackStopped",
|
||||||
|
Data = sessionInfo
|
||||||
|
|
||||||
|
}, cancellationToken);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user