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