Skip to content

Commit

Permalink
add - doc - Implemented repeat checkpoints
Browse files Browse the repository at this point in the history
---

We've implemented the repeat checkpoints that you can seek to.

---

Type: add
Breaking: False
Doc Required: True
Part: 1/1
  • Loading branch information
AptiviCEO committed May 30, 2024
1 parent f0187d8 commit 0621cae
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions BassBoom.Cli/CliBase/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ [R] Remove current song
[G] (when playing) Seek to next lyric
[J] (when playing) Seek to current lyric
[K] (when playing) Seek to which lyric
[C] Set repeat checkpoint
[SHIFT] + [C] Seek to repeat checkpoint
[E] Opens the equalizer
[D] (when playing) Device and driver info
[Z] System info
Expand Down
16 changes: 16 additions & 0 deletions BassBoom.Cli/CliBase/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ private static void HandleKeypressIdleMode(ConsoleKeyInfo keystroke, Screen play
else
PlayerControls.RemoveCurrentSong();
break;
case ConsoleKey.C:
if (Common.CurrentCachedInfo is null)
return;
if (keystroke.Modifiers == ConsoleModifiers.Shift)
PlayerControls.SeekTo(Common.CurrentCachedInfo.RepeatCheckpoint);
else
Common.CurrentCachedInfo.RepeatCheckpoint = PlaybackPositioningTools.GetCurrentDurationSpan();
break;
default:
Common.HandleKeypressCommon(keystroke, playerScreen, false);
break;
Expand Down Expand Up @@ -262,6 +270,14 @@ private static void HandleKeypressPlayMode(ConsoleKeyInfo keystroke, Screen play
PlayerControls.Play();
playerScreen.RequireRefresh();
break;
case ConsoleKey.C:
if (Common.CurrentCachedInfo is null)
return;
if (keystroke.Modifiers == ConsoleModifiers.Shift)
PlayerControls.SeekTo(Common.CurrentCachedInfo.RepeatCheckpoint);
else
Common.CurrentCachedInfo.RepeatCheckpoint = PlaybackPositioningTools.GetCurrentDurationSpan();
break;
default:
Common.HandleKeypressCommon(keystroke, playerScreen, false);
break;
Expand Down
12 changes: 12 additions & 0 deletions BassBoom.Cli/CliBase/PlayerControls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@ internal static void SeekWhichLyric()
PlaybackPositioningTools.SeekLyric(lyric);
}

internal static void SeekTo(TimeSpan target)
{
// In case we have no songs in the playlist...
if (Common.cachedInfos.Count == 0)
return;

Player.position = (int)(target.TotalSeconds * Common.CurrentCachedInfo.FormatInfo.rate);
if (Player.position > Common.CurrentCachedInfo.Duration)
Player.position = 0;
PlaybackPositioningTools.SeekToFrame(Player.position);
}

internal static void Play()
{
// In case we have no songs in the playlist...
Expand Down
5 changes: 5 additions & 0 deletions BassBoom.Cli/Tools/CachedSongInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

using BassBoom.Basolia.Format;
using BassBoom.Basolia.Lyrics;
using System;

namespace BassBoom.Cli.Tools
{
Expand Down Expand Up @@ -68,6 +69,10 @@ internal class CachedSongInfo
/// Checks to see if this cached song info instance is a radio station or not
/// </summary>
public bool IsRadio { get; private set; }
/// <summary>
/// Repeat checkpoint (not for radio stations)
/// </summary>
public TimeSpan RepeatCheckpoint { get; internal set; } = new();

/// <summary>
/// A cached song information
Expand Down

0 comments on commit 0621cae

Please sign in to comment.