Re-think what can be played

develop
LEdoian 3 years ago
parent 130e6d9573
commit 73a93a7462

@ -233,12 +233,9 @@ namespace QuickPlay
Identifier = id; Identifier = id;
Metadata = new PlayableMetadata Metadata = new PlayableMetadata
{ {
usualPlayingTime = TimeSpan.Parse(data["time"]) usualPlayingTime = TimeSpan.Parse(data["time"]),
filePath = data["path"],
}; };
} }
public void Play()
{
throw new NotImplementedException();
}
} }
} }

@ -19,10 +19,10 @@ namespace QuickPlay
} }
Dictionary<string, IPlayable> Songs { get; } Dictionary<string, IPlayable> Songs { get; }
string PlayerName { get; } string PlayerName { get; }
void Play(string identifier); Task Play(IPlayable playable);
float CurrentProgress { get; } float CurrentProgress { get; }
PlayerStatus Status { get; } PlayerStatus Status { get; }
void SetReasonableOptions(); //TODO Task SetReasonableOptions();
/// <summary> /// <summary>
/// Attach to the real player. /// Attach to the real player.
/// ///
@ -43,11 +43,11 @@ namespace QuickPlay
public class PlayableMetadata public class PlayableMetadata
{ {
public TimeSpan usualPlayingTime; public TimeSpan usualPlayingTime;
public string filePath;
} }
public interface IPlayable public interface IPlayable
{ {
void Play();
string Identifier { get; } string Identifier { get; }
PlayableMetadata Metadata { get; } PlayableMetadata Metadata { get; }
} }

@ -144,9 +144,9 @@ namespace QuickPlay
); );
} }
public void OnSongClick(object sender, IPlayable song) public async void OnSongClick(object sender, IPlayable song)
{ {
throw new NotImplementedException("Song click."); await currentPlayer.Play(song);
} }
} }
} }

@ -25,13 +25,19 @@ namespace QuickPlay
public float CurrentProgress { get { public float CurrentProgress { get {
throw new NotImplementedException(); throw new NotImplementedException();
} } } }
public void Play(string songId) public async Task Play(IPlayable song)
{ {
throw new NotImplementedException(); await SetReasonableOptions();
await mpd.SendAsync(new MpcCore.Commands.Queue.ClearQueue());
await mpd.SendAsync(new MpcCore.Commands.Queue.AddToQueue(song.Metadata.filePath));
await mpd.SendAsync(new MpcCore.Commands.Player.Play());
} }
public void SetReasonableOptions() public async Task SetReasonableOptions()
{ {
throw new NotImplementedException(); await mpd.SendAsync(new MpcCore.Commands.Options.SetConsume(true));
await mpd.SendAsync(new MpcCore.Commands.Options.SetRandom(false));
await mpd.SendAsync(new MpcCore.Commands.Options.SetRepeat(false));
await mpd.SendAsync(new MpcCore.Commands.Options.SetSingle(false));
} }
public MpdPlayer(PlayerConfiguration cfg) public MpdPlayer(PlayerConfiguration cfg)
{ {

Loading…
Cancel
Save