mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-23 18:44:45 +01:00
control remote players with now playing bar
This commit is contained in:
@@ -46,6 +46,16 @@ namespace MediaBrowser.Server.Implementations.Roku
|
||||
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)
|
||||
{
|
||||
return SendCommand(new WebSocketMessage<MessageCommand>
|
||||
|
||||
@@ -444,6 +444,8 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
MediaSourceId = info.MediaSourceId
|
||||
|
||||
}, _logger);
|
||||
|
||||
await SendPlaybackStartNotification(session, CancellationToken.None).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -583,6 +585,8 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
MediaSourceId = mediaSourceId
|
||||
|
||||
}, _logger);
|
||||
|
||||
await SendPlaybackStoppedNotification(session, CancellationToken.None).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private string GetMediaSourceId(BaseItem item, string reportedMediaSourceId)
|
||||
@@ -972,7 +976,6 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
return Task.WhenAll(tasks);
|
||||
}
|
||||
|
||||
|
||||
public Task SendSessionEndedNotification(SessionInfo sessionInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
var sessions = Sessions.Where(i => i.IsActive && i.SessionController != null).ToList();
|
||||
@@ -994,6 +997,48 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
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>
|
||||
/// Adds the additional user.
|
||||
/// </summary>
|
||||
@@ -1163,6 +1208,11 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
|
||||
info.PrimaryImageTag = GetImageCacheTag(item, ImageType.Primary);
|
||||
|
||||
if (info.PrimaryImageTag.HasValue)
|
||||
{
|
||||
info.PrimaryImageItemId = GetDtoId(item);
|
||||
}
|
||||
|
||||
var backropItem = item.HasImage(ImageType.Backdrop) ? item : null;
|
||||
|
||||
var thumbItem = item.HasImage(ImageType.Thumb) ? item : null;
|
||||
|
||||
@@ -210,5 +210,29 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
|
||||
}, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user