Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mpd support #56

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
f907b54
add mpd backend support
tramhao May 12, 2021
fd2c10a
add mpd.go
tramhao May 12, 2021
fd94c21
fix playlist_test
tramhao May 12, 2021
a76a96c
minor fix
tramhao May 12, 2021
3c57fe7
minor fix
tramhao May 13, 2021
21fa996
minor fix
tramhao May 13, 2021
6f500c5
Fix: refresh mpd database after rename or paste files
tramhao May 13, 2021
0a70ca5
Fix GetLength is not working for mpd
tramhao May 13, 2021
c6b1d7d
fix race condition in mpd
tramhao May 14, 2021
6fea854
Fix: skip not working for mpd when paused
tramhao May 14, 2021
306dbac
Use RWMutex instead of Mutex, to be more efficient
tramhao May 15, 2021
84e2388
better handle of errno in playingbar.go
tramhao May 17, 2021
ebd210f
release album photo when quitting
tramhao May 17, 2021
f82d5e3
change to RWMutex in mpd.go
tramhao May 17, 2021
9c73c62
remove unsafe method off getConsoleSize
tramhao May 17, 2021
23498e8
minor fix: race condition in updatePhoto
tramhao May 17, 2021
9649f37
minor fix: date race in songfinish
tramhao May 17, 2021
eaf5d2b
minor fix: data race in playingbar.go
tramhao May 18, 2021
35b0740
Refactor: lyricLang moved to lyric package
tramhao May 18, 2021
3846984
minor fix: error message showing when press N continuously
tramhao May 19, 2021
274aea9
Refactoring: queue.go:updateTitle
tramhao May 19, 2021
d791f14
Refactoring: move sha1Hex to utils.go
tramhao May 19, 2021
14691ab
minor fix: mpd.go
tramhao May 19, 2021
f0a3b51
minor fix: work in progress, fixing error message when pressing Skip …
tramhao May 20, 2021
6c5eb76
work in progress: fixing mpd.go error messages
tramhao May 20, 2021
e6aeb69
Minor fix: adjust location of picture
tramhao May 21, 2021
d6b1d07
fix: error message when press N key continuously
tramhao May 21, 2021
5b6450d
fixing mpd
tramhao May 21, 2021
72c6f05
Revert "fixing mpd"
tramhao May 23, 2021
d84e628
Revert "fix: error message when press N key continuously"
tramhao May 23, 2021
256a0af
Revert "Minor fix: adjust location of picture"
tramhao May 23, 2021
ee41a4d
Revert "work in progress: fixing mpd.go error messages"
tramhao May 23, 2021
99d5f7e
Fixing mpd.go
tramhao May 23, 2021
fcaa220
fix race condition in albumphoto
tramhao May 23, 2021
57075ff
Fix: playingbar.run cannot break when skip
tramhao May 26, 2021
42ea2ae
remove unused update channel in playingbar
tramhao May 27, 2021
e08a9a6
Revert "remove unused update channel in playingbar"
tramhao May 27, 2021
998b5f0
Minor Fix: clear mpq playlist when quit
tramhao May 27, 2021
2a47f74
Minor Fix: data race in playingbar.
tramhao May 28, 2021
a37bd8a
Minor Fix: data race in albumPhoto
tramhao May 28, 2021
3f6cc07
Minor Fix: avoid blocking progress bar for long lyrics
tramhao May 28, 2021
617eea4
minor fix: skip not working with beep backend
tramhao May 29, 2021
967e9e1
Minor fix: wrong photo position in alacritty
tramhao Jun 2, 2021
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
14 changes: 9 additions & 5 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"sync"

"github.com/issadarkthing/gomu/player"
"github.com/rivo/tview"
"github.com/ztrue/tracerr"
)
Expand Down Expand Up @@ -223,7 +222,9 @@ func (c Command) defineCommands() {
gomu.queue.pushFront(a)

if gomu.player.IsRunning() {
gomu.player.Skip()
if err := gomu.player.Skip(); err != nil {
errorPopup(err)
}
} else {
gomu.queue.playQueue()
}
Expand Down Expand Up @@ -280,23 +281,26 @@ func (c Command) defineCommands() {
})

c.define("volume_up", func() {
v := player.VolToHuman(gomu.player.GetVolume())
v := gomu.player.VolToHuman(gomu.player.GetVolume())
if v < 100 {
vol := gomu.player.SetVolume(0.5)
volumePopup(vol)
}
})

c.define("volume_down", func() {
v := player.VolToHuman(gomu.player.GetVolume())
v := gomu.player.VolToHuman(gomu.player.GetVolume())
if v > 0 {
vol := gomu.player.SetVolume(-0.5)
volumePopup(vol)
}
})

c.define("skip", func() {
gomu.player.Skip()
gomu.playingBar.stop()
if err := gomu.player.Skip(); err != nil {
errorPopup(err)
}
})

c.define("toggle_help", func() {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/disintegration/imaging v1.6.2
github.com/faiface/beep v1.0.2
github.com/fhs/gompd/v2 v2.2.0
github.com/gdamore/tcell/v2 v2.2.0
github.com/gobwas/glob v0.2.3 // indirect
github.com/gocolly/colly v1.2.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
github.com/faiface/beep v1.0.2 h1:UB5DiRNmA4erfUYnHbgU4UB6DlBOrsdEFRtcc8sCkdQ=
github.com/faiface/beep v1.0.2/go.mod h1:1yLb5yRdHMsovYYWVqYLioXkVuziCSITW1oarTeduQM=
github.com/fhs/gompd/v2 v2.2.0 h1:zdSYAAOzQ5cCCgYa5CoXkL0Vr0Cqb/b5JmTobirLc90=
github.com/fhs/gompd/v2 v2.2.0/go.mod h1:nNdZtcpD5VpmzZbRl5rV6RhxeMmAWTxEsSIMBkmMIy4=
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
github.com/gdamore/tcell v1.1.1/go.mod h1:K1udHkiR3cOtlpKG5tZPD5XxrF7v2y7lDq7Whcj+xkQ=
Expand Down
20 changes: 18 additions & 2 deletions gomu.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Gomu struct {
playingBar *PlayingBar
queue *Queue
playlist *Playlist
player *player.Player
player player.Player
pages *tview.Pages
colors *Colors
command Command
Expand Down Expand Up @@ -49,11 +49,16 @@ func newGomu() *Gomu {
// constructor function `newGomu` so that we can
// test independently
func (g *Gomu) initPanels(app *tview.Application, args Args) {
var err error
g.app = app
g.playingBar = newPlayingBar()
g.queue = newQueue()
g.playlist = newPlaylist(args)
g.player = player.New(g.anko.GetInt("General.volume"))
g.player, err = player.NewPlayer(g.anko.GetInt("General.volume"), g.anko.GetString("General.backend_server"), g.anko.GetString("General.mpd_port"))
if err != nil {
logError(err)
}

g.pages = tview.NewPages()
g.panels = []Panel{g.playlist, g.queue, g.playingBar}
}
Expand Down Expand Up @@ -146,6 +151,17 @@ func (g *Gomu) quit(args Args) error {
}
}

err := gomu.player.Stop()
if err != nil {
return tracerr.Wrap(err)
}

if gomu.playingBar.albumPhoto != nil {
gomu.playingBar.albumPhoto.Clear()
gomu.playingBar.albumPhoto.Destroy()
gomu.playingBar.albumPhoto = nil
}

gomu.app.Stop()

return nil
Expand Down
13 changes: 13 additions & 0 deletions lyric/lyric.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ type LyricFetcher interface {
LyricOptions(search string) ([]*SongTag, error)
}

func LyricLang(lang string) LyricFetcher {

switch lang {
case "en":
return LyricFetcherEn{}
case "zh-CN":
return LyricFetcherCn{}
default:
return LyricFetcherEn{}
}

}

// cleanHTML parses html text to valid utf-8 text
func cleanHTML(input string) string {

Expand Down
Loading