mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
playback start websocket
This commit is contained in:
@@ -1903,15 +1903,60 @@ public class JellyfinController : ControllerBase
|
|||||||
|
|
||||||
// For local tracks, forward to Jellyfin with client auth
|
// For local tracks, forward to Jellyfin with client auth
|
||||||
_logger.LogInformation("Forwarding playback start to Jellyfin...");
|
_logger.LogInformation("Forwarding playback start to Jellyfin...");
|
||||||
var (result, statusCode) = await _proxyService.PostJsonAsync("Sessions/Playing", body, Request.Headers);
|
|
||||||
|
// Fetch full item details to include in playback report
|
||||||
|
// This makes the session show up properly in Jellyfin dashboard with "Now Playing"
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var (itemResult, itemStatus) = await _proxyService.GetJsonAsync($"Items/{itemId}", null, Request.Headers);
|
||||||
|
if (itemResult != null && itemStatus == 200)
|
||||||
|
{
|
||||||
|
var item = itemResult.RootElement;
|
||||||
|
_logger.LogInformation("📦 Fetched item details for playback report");
|
||||||
|
|
||||||
|
// Build enhanced playback start info with full item details
|
||||||
|
var enhancedBody = new
|
||||||
|
{
|
||||||
|
ItemId = itemId,
|
||||||
|
PositionTicks = doc.RootElement.TryGetProperty("PositionTicks", out var posProp) ? posProp.GetInt64() : 0,
|
||||||
|
// Include the full item so Jellyfin can display "Now Playing"
|
||||||
|
NowPlayingItem = item.Clone()
|
||||||
|
};
|
||||||
|
|
||||||
|
var enhancedJson = JsonSerializer.Serialize(enhancedBody);
|
||||||
|
_logger.LogInformation("📤 Sending enhanced playback start with item details");
|
||||||
|
|
||||||
|
var (result, statusCode) = await _proxyService.PostJsonAsync("Sessions/Playing", enhancedJson, Request.Headers);
|
||||||
|
|
||||||
if (statusCode == 204 || statusCode == 200)
|
if (statusCode == 204 || statusCode == 200)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("✓ Playback start forwarded to Jellyfin ({StatusCode})", statusCode);
|
_logger.LogInformation("✓ Enhanced playback start forwarded to Jellyfin ({StatusCode})", statusCode);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_logger.LogWarning("⚠️ Playback start forward returned status {StatusCode}", statusCode);
|
_logger.LogWarning("⚠️ Enhanced playback start returned status {StatusCode}", statusCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.LogWarning("⚠️ Could not fetch item details ({StatusCode}), sending basic playback start", itemStatus);
|
||||||
|
// Fall back to basic playback start
|
||||||
|
var (result, statusCode) = await _proxyService.PostJsonAsync("Sessions/Playing", body, Request.Headers);
|
||||||
|
if (statusCode == 204 || statusCode == 200)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("✓ Basic playback start forwarded to Jellyfin ({StatusCode})", statusCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, "Failed to send enhanced playback start, trying basic");
|
||||||
|
// Fall back to basic playback start
|
||||||
|
var (result, statusCode) = await _proxyService.PostJsonAsync("Sessions/Playing", body, Request.Headers);
|
||||||
|
if (statusCode == 204 || statusCode == 200)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("✓ Basic playback start forwarded to Jellyfin ({StatusCode})", statusCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NoContent();
|
return NoContent();
|
||||||
|
|||||||
Reference in New Issue
Block a user