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> /// </summary>
public interface IPlayer public interface IPlayer
{ {
public enum PlayerStatus
{
Disconnected, Playing, Stopped
}
Dictionary<string, IPlayable> Songs { get; } Dictionary<string, IPlayable> Songs { get; }
string PlayerName { get; } string PlayerName { get; }
void Play(string identifier); void Play(string identifier);
float CurrentProgress { get; } float CurrentProgress { get; }
bool IsReady { get; } PlayerStatus Status { get; }
void SetReasonableOptions(); //TODO void SetReasonableOptions(); //TODO
/// <summary> /// <summary>
/// Attach to the real player. /// Attach to the real player.

@ -113,10 +113,33 @@ namespace QuickPlay
{ {
TextView playerName = FindViewById<TextView>(Resource.Id.playerNameText); TextView playerName = FindViewById<TextView>(Resource.Id.playerNameText);
playerName.Text = currentPlayer.PlayerName; 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); Toolbar tb = FindViewById<Toolbar>(Resource.Id.toolbar);
// This code is seriously lovely. FML. tb.SetBackgroundColor(
tb.SetBackgroundColor(currentPlayer.IsReady ? new Android.Graphics.Color(Android.Support.V4.Content.ContextCompat.GetColor(this, Resource.Color.colorPrimary)) : Android.Graphics.Color.Red); new Android.Graphics.Color(
// throw new NotImplementedException("Activity should update."); Android.Support.V4.Content.ContextCompat.GetColor(this, Resource.Color.colorPrimary)
)
);
} }
} }
} }

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

Loading…
Cancel
Save