You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.0 KiB
C#
65 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
|
|
// MPD client abstractions and simplifications
|
|
namespace QuickPlay
|
|
{
|
|
/// <summary>
|
|
/// Simplified abstraction of possible players. Only methods needed are included.
|
|
///
|
|
/// That means that the interface may be extended in the future, which is sad.
|
|
/// </summary>
|
|
public interface IPlayer
|
|
{
|
|
public enum PlayerStatus
|
|
{
|
|
Disconnected, Playing, Stopped
|
|
}
|
|
Dictionary<string, IPlayable> Songs { get; }
|
|
string PlayerName { get; }
|
|
Task Play(IPlayable playable);
|
|
float CurrentProgress { get; }
|
|
PlayerStatus Status { get; }
|
|
Task SetReasonableOptions();
|
|
/// <summary>
|
|
/// Attach to the real player.
|
|
///
|
|
/// Since this operation can be asynchronous, we cannot put it in th
|
|
/// constructor. And this allows for some tweaks before connecting.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
Task ConnectAsync();
|
|
}
|
|
/// <summary>
|
|
/// A simple dataclass to hold auxiliary data of the Playable objects.
|
|
/// </summary>
|
|
// This is not really an interface, but since it is a dataclass, I treat it
|
|
// more as a part of interface, so it belongs to this file.
|
|
|
|
// Also, in order not to need boilerplate code, this should be semantically
|
|
// treated as immutable even though it's not.
|
|
public class PlayableMetadata
|
|
{
|
|
public TimeSpan usualPlayingTime;
|
|
public string filePath;
|
|
}
|
|
|
|
public interface IPlayable
|
|
{
|
|
string Identifier { get; }
|
|
PlayableMetadata Metadata { get; }
|
|
}
|
|
interface ILayoutStrategy
|
|
{
|
|
List<IPlayable> LayOut(ICollection<IPlayable> playables);
|
|
}
|
|
|
|
public class CannotConnectException: Exception
|
|
{
|
|
public CannotConnectException(string msg, Exception e) : base(msg, e) { }
|
|
public CannotConnectException(string msg) : base(msg) { }
|
|
public CannotConnectException() : base() { }
|
|
}
|
|
|
|
} |