Change IsReady to Status

It really isn't an ortogonal state.
develop
LEdoian 3 years ago
parent a4ecbd84ed
commit a8d9d7504d

@ -13,11 +13,15 @@ namespace QuickPlay
/// </summary>
public interface IPlayer
{
public enum PlayerStatus
{
Disconnected, Playing, Stopped
}
Dictionary<string, IPlayable> Songs { get; }
string PlayerName { get; }
void Play(string identifier);
float CurrentProgress { get; }
bool IsReady { get; }
PlayerStatus Status { get; }
void SetReasonableOptions(); //TODO
/// <summary>
/// Attach to the real player.

@ -113,10 +113,33 @@ namespace QuickPlay
{
TextView playerName = FindViewById<TextView>(Resource.Id.playerNameText);
playerName.Text = currentPlayer.PlayerName;
var bar = FindViewById(Resource.Id.currentSongBar);
switch (currentPlayer.Status)
{
case IPlayer.PlayerStatus.Disconnected:
Toolbar tb = FindViewById<Toolbar>(Resource.Id.toolbar);
tb.SetBackgroundColor(Android.Graphics.Color.Red);
bar.Visibility = ViewStates.Invisible;
break;
case IPlayer.PlayerStatus.Playing:
ResetToolbarColor();
// Show progress bar
bar.Visibility = ViewStates.Visible;
break;
case IPlayer.PlayerStatus.Stopped:
ResetToolbarColor();
bar.Visibility = ViewStates.Invisible;
break;
}
}
private void ResetToolbarColor()
{
Toolbar tb = FindViewById<Toolbar>(Resource.Id.toolbar);
// This code is seriously lovely. FML.
tb.SetBackgroundColor(currentPlayer.IsReady ? new Android.Graphics.Color(Android.Support.V4.Content.ContextCompat.GetColor(this, Resource.Color.colorPrimary)) : Android.Graphics.Color.Red);
// throw new NotImplementedException("Activity should update.");
tb.SetBackgroundColor(
new Android.Graphics.Color(
Android.Support.V4.Content.ContextCompat.GetColor(this, Resource.Color.colorPrimary)
)
);
}
}
}

@ -18,16 +18,13 @@ namespace QuickPlay
MpcCoreClient mpd;
// MpcCore uses strings, so be it
string mpdIP, mpdPort;
public IPlayer.PlayerStatus Status { get; private set; }
public Dictionary<string, IPlayable> Songs { get; private set; }
public string PlayerName { get; private set; }
public float CurrentProgress { get {
throw new NotImplementedException();
} }
public bool IsReady { get
{
return mpd.IsConnected;
} }
public void Play(string songId)
{
throw new NotImplementedException();
@ -47,6 +44,8 @@ namespace QuickPlay
mpdIP = connDetails[0];
mpdPort = connDetails.Length >=2 ? connDetails[1] : "6600"; // XXX: Unneccessary default here...
// Connecting and monitoring remote player is done in ConnectAsync.
// Therefore, we start disconnected
Status = IPlayer.PlayerStatus.Disconnected;
}
public async Task ConnectAsync()
{

Loading…
Cancel
Save