control remote players with now playing bar

This commit is contained in:
Luke Pulverenti
2014-04-12 13:27:53 -04:00
parent 3817ff36b0
commit b6ca79b73f
8 changed files with 119 additions and 6 deletions

View File

@@ -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;

View File

@@ -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);
}
}
}