Duncan Tourolle 2f5a182afd
Some checks failed
🏗️ Build Plugin / call (push) Failing after 0s
📝 Create/Update Release Draft & Release Bump PR / call (push) Failing after 0s
🔬 Run CodeQL / call (push) Failing after 0s
🧪 Test Plugin / call (push) Failing after 0s
First POC with working playback
2025-12-13 23:54:33 +01:00

255 lines
6.2 KiB
C#

using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace Jellyfin.Plugin.JellyLMS.Models;
/// <summary>
/// JSON-RPC request for LMS API.
/// </summary>
public class LmsJsonRpcRequest
{
/// <summary>
/// Gets or sets the request ID.
/// </summary>
[JsonPropertyName("id")]
public int Id { get; set; } = 1;
/// <summary>
/// Gets or sets the method name (always "slim.request").
/// </summary>
[JsonPropertyName("method")]
public string Method { get; set; } = "slim.request";
/// <summary>
/// Gets or sets the parameters [playerMac, [command, args...]].
/// </summary>
[JsonPropertyName("params")]
public object[] Params { get; set; } = [];
}
/// <summary>
/// JSON-RPC response from LMS API.
/// </summary>
/// <typeparam name="T">The result type.</typeparam>
public class LmsJsonRpcResponse<T>
{
/// <summary>
/// Gets or sets the request ID.
/// </summary>
[JsonPropertyName("id")]
public int Id { get; set; }
/// <summary>
/// Gets or sets the result data.
/// </summary>
[JsonPropertyName("result")]
public T? Result { get; set; }
/// <summary>
/// Gets or sets any error message.
/// </summary>
[JsonPropertyName("error")]
public string? Error { get; set; }
}
/// <summary>
/// Player count response.
/// </summary>
public class PlayerCountResult
{
/// <summary>
/// Gets or sets the count value.
/// </summary>
[JsonPropertyName("_count")]
public int Count { get; set; }
}
/// <summary>
/// Players list response.
/// </summary>
public class PlayersListResult
{
/// <summary>
/// Gets or sets the player count.
/// </summary>
[JsonPropertyName("count")]
public int Count { get; set; }
/// <summary>
/// Gets or sets the list of players.
/// </summary>
[JsonPropertyName("players_loop")]
public List<LmsPlayerInfo> Players { get; set; } = [];
}
/// <summary>
/// Player info from LMS API.
/// </summary>
public class LmsPlayerInfo
{
/// <summary>
/// Gets or sets the player name.
/// </summary>
[JsonPropertyName("name")]
public string Name { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the player ID (MAC address).
/// </summary>
[JsonPropertyName("playerid")]
public string PlayerId { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the player IP address.
/// </summary>
[JsonPropertyName("ip")]
public string Ip { get; set; } = string.Empty;
/// <summary>
/// Gets or sets whether the player is connected.
/// </summary>
[JsonPropertyName("connected")]
public int Connected { get; set; }
/// <summary>
/// Gets or sets the power state.
/// </summary>
[JsonPropertyName("power")]
public int Power { get; set; }
/// <summary>
/// Gets or sets the player model.
/// </summary>
[JsonPropertyName("model")]
public string Model { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the player model name.
/// </summary>
[JsonPropertyName("modelname")]
public string ModelName { get; set; } = string.Empty;
}
/// <summary>
/// Player status response.
/// </summary>
public class PlayerStatusResult
{
/// <summary>
/// Gets or sets the player name.
/// </summary>
[JsonPropertyName("player_name")]
public string PlayerName { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the player connected state.
/// </summary>
[JsonPropertyName("player_connected")]
public int PlayerConnected { get; set; }
/// <summary>
/// Gets or sets the power state.
/// </summary>
[JsonPropertyName("power")]
public int Power { get; set; }
/// <summary>
/// Gets or sets the playback mode (play, pause, stop).
/// </summary>
[JsonPropertyName("mode")]
public string Mode { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the current time position in seconds.
/// </summary>
[JsonPropertyName("time")]
public double Time { get; set; }
/// <summary>
/// Gets or sets the mixer volume (0-100).
/// </summary>
[JsonPropertyName("mixer volume")]
public int Volume { get; set; }
/// <summary>
/// Gets or sets the total duration in seconds.
/// </summary>
[JsonPropertyName("duration")]
public double Duration { get; set; }
/// <summary>
/// Gets or sets the sync master MAC address.
/// </summary>
[JsonPropertyName("sync_master")]
public string? SyncMaster { get; set; }
/// <summary>
/// Gets or sets the list of synced player MACs.
/// </summary>
[JsonPropertyName("sync_slaves")]
public string? SyncSlaves { get; set; }
/// <summary>
/// Gets or sets the current track title.
/// </summary>
[JsonPropertyName("current_title")]
public string? CurrentTitle { get; set; }
}
/// <summary>
/// LMS server status.
/// </summary>
public class LmsServerStatus
{
/// <summary>
/// Gets or sets the server version.
/// </summary>
public string Version { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the player count.
/// </summary>
public int PlayerCount { get; set; }
/// <summary>
/// Gets or sets whether the server is reachable.
/// </summary>
public bool IsConnected { get; set; }
/// <summary>
/// Gets or sets the last error message.
/// </summary>
public string? LastError { get; set; }
}
/// <summary>
/// Sync group information.
/// </summary>
public class SyncGroup
{
/// <summary>
/// Gets or sets the master player MAC address.
/// </summary>
public string MasterMac { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the master player name.
/// </summary>
public string MasterName { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the slave player MAC addresses.
/// </summary>
public List<string> SlaveMacs { get; set; } = [];
/// <summary>
/// Gets or sets the slave player names.
/// </summary>
public List<string> SlaveNames { get; set; } = [];
/// <summary>
/// Gets the total number of players in this sync group.
/// </summary>
public int PlayerCount => 1 + SlaveMacs.Count;
}