Skip to content

Commit

Permalink
Merge pull request #35 from braheezy/player-rewrite
Browse files Browse the repository at this point in the history
Player rewrite
  • Loading branch information
braheezy authored May 4, 2024
2 parents 6762e72 + 8c70bfe commit b1d5e6b
Show file tree
Hide file tree
Showing 9 changed files with 307 additions and 180 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ jobs:
name: windows
path: goqoa.exe
build-mac:
runs-on: macos-latest
# The OGG to QOA conversion test fails on macOS 14 because the checksum doesn't match.
# That doesn't feel like my problem so we'll stay on macOS 12 for now.
runs-on: macos-12
env:
GO111MODULE: "on"
CGO_ENABLED: 1
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ PACKAGE := goqoa
GOCMD ?= go
GOBUILD := $(GOCMD) build
GOINSTALL := $(GOCMD) install
GORUN := $(GOCMD) run
GOARCH := amd64

# Build definitions
Expand Down Expand Up @@ -88,3 +89,6 @@ install: $(BIN)
@echo -e "$(YELLOW)🚀 Installing $(BIN) to appropriate location...$(END)"
@$(GOINSTALL) $(BUILD_ENTRY)
@echo -e "$(GREEN)✅ Installation complete!$(END)"

playrun:
@$(GORUN) . play four_tet_baby.qoa
25 changes: 19 additions & 6 deletions cmd/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ package cmd
import "github.com/charmbracelet/bubbles/key"

type helpKeyMap struct {
togglePlay key.Binding
quit key.Binding
togglePlay key.Binding
quit key.Binding
seek key.Binding
seekBack key.Binding
seekForward key.Binding
}

var helpsKeys = helpKeyMap{
var helpKeys = helpKeyMap{
togglePlay: key.NewBinding(
key.WithKeys(" ", "p"),
key.WithHelp("space/p", "play/pause"),
Expand All @@ -16,14 +19,24 @@ var helpsKeys = helpKeyMap{
key.WithKeys("q", "esc", "ctrl+c"),
key.WithHelp("q/esc", "quit"),
),
seek: key.NewBinding(
key.WithKeys("left", "h", "right", "l"),
key.WithHelp("left/h/right/l", "seek"),
),
seekBack: key.NewBinding(
key.WithKeys("left", "h"),
),
seekForward: key.NewBinding(
key.WithKeys("right", "l"),
),
}

func (k helpKeyMap) ShortHelp() []key.Binding {
return []key.Binding{k.togglePlay, k.quit}
return []key.Binding{k.togglePlay, k.seek, k.quit}
}
func (k helpKeyMap) FullHelp() [][]key.Binding {
return [][]key.Binding{
{k.togglePlay}, // first column
{k.quit}, // second column
{k.togglePlay, k.seek}, // first column
{k.quit}, // second column
}
}
9 changes: 5 additions & 4 deletions cmd/play.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ var playCmd = &cobra.Command{
}
}
}
if len(allFiles) == 0 {
fmt.Println("No valid QOA files found :(")
return
}
startTUI(allFiles)
},
}
Expand All @@ -53,10 +57,7 @@ func findAllQOAFiles(root string) ([]string, error) {
return err
}
if !info.IsDir() {
valid, err := qoa.IsValidQOAFile(path)
if err != nil {
return err
}
valid, _ := qoa.IsValidQOAFile(path)
if valid {
files = append(files, path)
}
Expand Down
43 changes: 0 additions & 43 deletions cmd/qoaaudioreader.go

This file was deleted.

5 changes: 1 addition & 4 deletions cmd/style.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,5 @@ const (
)

var (
statusStyle = lipgloss.NewStyle().
Italic(true).
Padding(1, 1).
Foreground(lipgloss.Color(qoaPink))
accent = lipgloss.AdaptiveColor{Dark: "#81dd97", Light: "#217b37"}
)
Loading

0 comments on commit b1d5e6b

Please sign in to comment.