184 lines
4.1 KiB
C#
184 lines
4.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Jellyfin.Plugin.JellyLMS.Models;
|
|
|
|
/// <summary>
|
|
/// Represents the current playback state.
|
|
/// </summary>
|
|
public enum PlaybackState
|
|
{
|
|
/// <summary>
|
|
/// Device connected, no media loaded.
|
|
/// </summary>
|
|
Idle,
|
|
|
|
/// <summary>
|
|
/// Play command sent, waiting for LMS to confirm playback started.
|
|
/// </summary>
|
|
Loading,
|
|
|
|
/// <summary>
|
|
/// Playback is active.
|
|
/// </summary>
|
|
Playing,
|
|
|
|
/// <summary>
|
|
/// Playback is paused.
|
|
/// </summary>
|
|
Paused,
|
|
|
|
/// <summary>
|
|
/// Position change in progress.
|
|
/// </summary>
|
|
Seeking,
|
|
|
|
/// <summary>
|
|
/// Playback failed with an error.
|
|
/// </summary>
|
|
Error,
|
|
|
|
/// <summary>
|
|
/// Playback has ended.
|
|
/// </summary>
|
|
Stopped
|
|
}
|
|
|
|
/// <summary>
|
|
/// Types of playback errors.
|
|
/// </summary>
|
|
public enum PlaybackErrorType
|
|
{
|
|
/// <summary>
|
|
/// No error.
|
|
/// </summary>
|
|
None,
|
|
|
|
/// <summary>
|
|
/// Operation timed out waiting for LMS response.
|
|
/// </summary>
|
|
Timeout,
|
|
|
|
/// <summary>
|
|
/// Network error communicating with LMS.
|
|
/// </summary>
|
|
NetworkError,
|
|
|
|
/// <summary>
|
|
/// LMS returned an error.
|
|
/// </summary>
|
|
LmsError,
|
|
|
|
/// <summary>
|
|
/// Error with the audio stream from Jellyfin.
|
|
/// </summary>
|
|
StreamError,
|
|
|
|
/// <summary>
|
|
/// Unknown error.
|
|
/// </summary>
|
|
Unknown
|
|
}
|
|
|
|
/// <summary>
|
|
/// Contains details about a playback error.
|
|
/// </summary>
|
|
public class PlaybackErrorInfo
|
|
{
|
|
/// <summary>
|
|
/// Gets or sets the type of error.
|
|
/// </summary>
|
|
public PlaybackErrorType ErrorType { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the error message.
|
|
/// </summary>
|
|
public string Message { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Gets or sets when the error occurred.
|
|
/// </summary>
|
|
public DateTime OccurredAt { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the number of retry attempts made.
|
|
/// </summary>
|
|
public int RetryCount { get; set; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Represents an active playback session bridging Jellyfin to LMS.
|
|
/// </summary>
|
|
public class LmsPlaybackSession
|
|
{
|
|
/// <summary>
|
|
/// Gets or sets the unique session identifier.
|
|
/// </summary>
|
|
public string SessionId { get; set; } = Guid.NewGuid().ToString();
|
|
|
|
/// <summary>
|
|
/// Gets or sets the Jellyfin session ID.
|
|
/// </summary>
|
|
public string? JellyfinSessionId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the Jellyfin item ID being played.
|
|
/// </summary>
|
|
public Guid ItemId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the item name for display.
|
|
/// </summary>
|
|
public string ItemName { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the artist name (for audio).
|
|
/// </summary>
|
|
public string? Artist { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the album name (for audio).
|
|
/// </summary>
|
|
public string? Album { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the MAC addresses of LMS players in this session.
|
|
/// </summary>
|
|
public List<string> PlayerMacs { get; set; } = [];
|
|
|
|
/// <summary>
|
|
/// Gets or sets the current playback state.
|
|
/// </summary>
|
|
public PlaybackState State { get; set; } = PlaybackState.Idle;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the last error that occurred during playback.
|
|
/// </summary>
|
|
public PlaybackErrorInfo? LastError { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the current playback position in ticks.
|
|
/// </summary>
|
|
public long PositionTicks { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the total runtime in ticks.
|
|
/// </summary>
|
|
public long RuntimeTicks { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets when this session started.
|
|
/// </summary>
|
|
public DateTime StartedAt { get; set; } = DateTime.UtcNow;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the audio stream URL being played on LMS.
|
|
/// </summary>
|
|
public string? StreamUrl { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the Jellyfin user ID who initiated playback.
|
|
/// </summary>
|
|
public Guid? UserId { get; set; }
|
|
}
|