Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/model/IPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,9 @@ public interface IPlayer
/// Method to stop audio playback.
/// </summary>
void Stop();

void IncreaseVolume();

void DecreaseVolume();
}
}
28 changes: 27 additions & 1 deletion src/model/WinPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,31 @@ public void OnPlaybackStopped(object sender, StoppedEventArgs args)
this.audioFileReader.Dispose();
this.outputDevice.Dispose();
}

public void IncreaseVolume()
{
// Use this construct to prevent edge cases going over 1.0f
// This is caused by using floats in WaveOutEvent
if (this.outputDevice.Volume > 0.9f)
{
this.outputDevice.Volume = 1.0f;
return;
}

this.outputDevice.Volume += 0.1f;
}

public void DecreaseVolume()
{
// Use this construct to prevent edge cases going under 0.0f
// This is caused by using floats in WaveOutEvent
if (this.outputDevice.Volume < 0.1f)
{
this.outputDevice.Volume = 0.0f;
return;
}

this.outputDevice.Volume -= 0.1f;
}
}
}
}
19 changes: 16 additions & 3 deletions src/view/Gui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public void Start()
var playBtn = new Button(1, 1, "Play");
playBtn.Clicked += () =>
{
if(this.player.LastFileOpened == null) {
if (this.player.LastFileOpened == null)
{
this.OpenFile();
return;
}
Expand All @@ -90,14 +91,25 @@ public void Start()
this.player.Pause();
};

// Add the playback components.
var stopBtn = new Button(20, 1, "Stop");
stopBtn.Clicked += () =>
{
this.player.Stop();
};

playbackControls.Add(stopBtn, pauseBtn, playBtn);
var increaseVolumeButton = new Button(29, 1, "+ Volume");
increaseVolumeButton.Clicked += () =>
{
this.player.IncreaseVolume();
};

var decreaseVolumeButton = new Button(42, 1, "- Volume");
decreaseVolumeButton.Clicked += () =>
{
this.player.DecreaseVolume();
};

playbackControls.Add(playBtn, pauseBtn, stopBtn, increaseVolumeButton, decreaseVolumeButton);

// Create the left-hand playlists view.
leftPane = new FrameView("Playlists")
Expand All @@ -120,6 +132,7 @@ public void Start()
AllowsMarking = false,
CanFocus = true,
};

categoryListView.OpenSelectedItem += (a) =>
{
rightPane.SetFocus();
Expand Down