2020-08-25 18:17:54 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-03-24 23:50:54 +08:00
|
|
|
"sync"
|
|
|
|
|
2021-02-26 11:18:58 +08:00
|
|
|
"github.com/issadarkthing/gomu/player"
|
2020-08-25 18:17:54 +08:00
|
|
|
"github.com/rivo/tview"
|
|
|
|
"github.com/ztrue/tracerr"
|
|
|
|
)
|
|
|
|
|
2021-03-25 12:01:12 +08:00
|
|
|
// Command map string to actual command function
|
2020-08-25 18:17:54 +08:00
|
|
|
type Command struct {
|
|
|
|
commands map[string]func()
|
|
|
|
}
|
|
|
|
|
|
|
|
func newCommand() Command {
|
|
|
|
return Command{
|
|
|
|
commands: make(map[string]func()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Command) define(name string, callBack func()) {
|
|
|
|
c.commands[name] = callBack
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c Command) getFn(name string) (func(), error) {
|
|
|
|
fn, ok := c.commands[name]
|
|
|
|
if !ok {
|
|
|
|
return nil, tracerr.New("command not found")
|
|
|
|
}
|
|
|
|
return fn, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c Command) defineCommands() {
|
|
|
|
|
2021-02-14 13:45:43 +08:00
|
|
|
anko := gomu.anko
|
|
|
|
|
2020-08-25 18:17:54 +08:00
|
|
|
/* Playlist */
|
|
|
|
|
|
|
|
c.define("create_playlist", func() {
|
|
|
|
name, _ := gomu.pages.GetFrontPage()
|
|
|
|
if name != "mkdir-popup" {
|
|
|
|
createPlaylistPopup()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
c.define("delete_playlist", func() {
|
|
|
|
audioFile := gomu.playlist.getCurrentFile()
|
2021-04-30 15:33:53 +08:00
|
|
|
if audioFile.IsAudioFile() {
|
2021-03-02 15:40:23 +08:00
|
|
|
return
|
|
|
|
}
|
2021-04-30 15:33:53 +08:00
|
|
|
err := confirmDeleteAllPopup(audioFile.Node())
|
2021-03-02 15:40:23 +08:00
|
|
|
if err != nil {
|
|
|
|
errorPopup(err)
|
2020-08-25 18:17:54 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
c.define("delete_file", func() {
|
|
|
|
audioFile := gomu.playlist.getCurrentFile()
|
|
|
|
// prevent from deleting a directory
|
2021-04-30 15:33:53 +08:00
|
|
|
if !audioFile.IsAudioFile() {
|
2020-08-25 18:17:54 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-04-08 03:04:39 +08:00
|
|
|
gomu.playlist.deleteSong(audioFile)
|
|
|
|
|
2020-08-25 18:17:54 +08:00
|
|
|
})
|
|
|
|
|
2021-02-04 21:27:17 +08:00
|
|
|
c.define("youtube_search", func() {
|
2021-02-20 16:21:04 +08:00
|
|
|
ytSearchPopup()
|
2021-02-04 21:27:17 +08:00
|
|
|
})
|
|
|
|
|
2020-08-25 18:17:54 +08:00
|
|
|
c.define("download_audio", func() {
|
|
|
|
|
|
|
|
audioFile := gomu.playlist.getCurrentFile()
|
|
|
|
currNode := gomu.playlist.GetCurrentNode()
|
2021-02-04 11:25:30 +08:00
|
|
|
if gomu.pages.HasPage("download-input-popup") {
|
|
|
|
gomu.pages.RemovePage("download-input-popup")
|
|
|
|
gomu.popups.pop()
|
2020-08-25 18:17:54 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
// this ensures it downloads to
|
|
|
|
// the correct dir
|
2021-04-30 15:33:53 +08:00
|
|
|
if audioFile.IsAudioFile() {
|
|
|
|
downloadMusicPopup(audioFile.ParentNode())
|
2020-08-25 18:17:54 +08:00
|
|
|
} else {
|
|
|
|
downloadMusicPopup(currNode)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
c.define("add_queue", func() {
|
|
|
|
audioFile := gomu.playlist.getCurrentFile()
|
|
|
|
currNode := gomu.playlist.GetCurrentNode()
|
2021-04-30 15:33:53 +08:00
|
|
|
if audioFile.IsAudioFile() {
|
2021-04-08 02:36:47 +08:00
|
|
|
gomu.queue.pushFront(audioFile)
|
2021-04-01 23:54:38 +08:00
|
|
|
if len(gomu.queue.items) == 1 && !gomu.player.IsRunning() {
|
|
|
|
err := gomu.queue.playQueue()
|
|
|
|
if err != nil {
|
|
|
|
errorPopup(err)
|
|
|
|
}
|
|
|
|
}
|
2020-08-25 18:17:54 +08:00
|
|
|
} else {
|
|
|
|
currNode.SetExpanded(true)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
c.define("close_node", func() {
|
|
|
|
audioFile := gomu.playlist.getCurrentFile()
|
|
|
|
currNode := gomu.playlist.GetCurrentNode()
|
|
|
|
// if closing node with no children
|
|
|
|
// close the node's parent
|
|
|
|
// remove the color of the node
|
|
|
|
|
2021-04-30 15:33:53 +08:00
|
|
|
if audioFile.IsAudioFile() {
|
|
|
|
parent := audioFile.ParentNode()
|
2020-08-25 18:17:54 +08:00
|
|
|
gomu.playlist.setHighlight(parent)
|
|
|
|
parent.SetExpanded(false)
|
|
|
|
}
|
|
|
|
currNode.Collapse()
|
|
|
|
})
|
|
|
|
|
|
|
|
c.define("bulk_add", func() {
|
|
|
|
currNode := gomu.playlist.GetCurrentNode()
|
2021-02-18 10:23:15 +08:00
|
|
|
bulkAdd := anko.GetBool("General.confirm_bulk_add")
|
2020-08-25 18:17:54 +08:00
|
|
|
|
2021-02-12 10:58:40 +08:00
|
|
|
if !bulkAdd {
|
2020-08-25 18:17:54 +08:00
|
|
|
gomu.playlist.addAllToQueue(currNode)
|
2021-04-02 09:44:47 +08:00
|
|
|
if len(gomu.queue.items) > 0 && !gomu.player.IsRunning() {
|
|
|
|
err := gomu.queue.playQueue()
|
|
|
|
if err != nil {
|
|
|
|
errorPopup(err)
|
|
|
|
}
|
|
|
|
}
|
2020-08-25 18:17:54 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
confirmationPopup(
|
|
|
|
"Are you sure to add this whole directory into queue?",
|
|
|
|
func(_ int, label string) {
|
|
|
|
|
|
|
|
if label == "yes" {
|
|
|
|
gomu.playlist.addAllToQueue(currNode)
|
2021-04-02 09:44:47 +08:00
|
|
|
if len(gomu.queue.items) > 0 && !gomu.player.IsRunning() {
|
|
|
|
err := gomu.queue.playQueue()
|
|
|
|
if err != nil {
|
|
|
|
errorPopup(err)
|
|
|
|
}
|
|
|
|
}
|
2020-08-25 18:17:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
c.define("refresh", func() {
|
|
|
|
gomu.playlist.refresh()
|
|
|
|
})
|
|
|
|
|
|
|
|
c.define("rename", func() {
|
|
|
|
audioFile := gomu.playlist.getCurrentFile()
|
|
|
|
renamePopup(audioFile)
|
|
|
|
})
|
|
|
|
|
|
|
|
c.define("playlist_search", func() {
|
|
|
|
|
|
|
|
files := make([]string, len(gomu.playlist.getAudioFiles()))
|
|
|
|
|
|
|
|
for i, file := range gomu.playlist.getAudioFiles() {
|
2021-04-30 15:33:53 +08:00
|
|
|
files[i] = file.Name()
|
2020-08-25 18:17:54 +08:00
|
|
|
}
|
|
|
|
|
2021-02-15 13:56:31 +08:00
|
|
|
searchPopup("Search", files, func(text string) {
|
2020-08-25 18:17:54 +08:00
|
|
|
|
|
|
|
audio, err := gomu.playlist.findAudioFile(sha1Hex(text))
|
|
|
|
if err != nil {
|
|
|
|
logError(err)
|
|
|
|
}
|
|
|
|
|
2021-04-30 15:33:53 +08:00
|
|
|
gomu.playlist.setHighlight(audio.Node())
|
2021-02-07 03:01:49 +08:00
|
|
|
gomu.playlist.refresh()
|
2020-08-25 18:17:54 +08:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2021-02-15 12:13:40 +08:00
|
|
|
c.define("reload_config", func() {
|
|
|
|
cfg := expandFilePath(*gomu.args.config)
|
|
|
|
err := execConfig(cfg)
|
|
|
|
if err != nil {
|
|
|
|
errorPopup(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
infoPopup("successfully reload config file")
|
|
|
|
})
|
|
|
|
|
2020-08-25 18:17:54 +08:00
|
|
|
/* Queue */
|
|
|
|
|
|
|
|
c.define("move_down", func() {
|
|
|
|
gomu.queue.next()
|
|
|
|
})
|
|
|
|
|
|
|
|
c.define("move_up", func() {
|
|
|
|
gomu.queue.prev()
|
|
|
|
})
|
|
|
|
|
|
|
|
c.define("delete_item", func() {
|
|
|
|
gomu.queue.deleteItem(gomu.queue.GetCurrentItem())
|
|
|
|
})
|
|
|
|
|
|
|
|
c.define("clear_queue", func() {
|
|
|
|
confirmationPopup("Are you sure to clear the queue?",
|
|
|
|
func(_ int, label string) {
|
|
|
|
if label == "yes" {
|
|
|
|
gomu.queue.clearQueue()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
c.define("play_selected", func() {
|
2021-02-03 10:50:01 +08:00
|
|
|
if gomu.queue.GetItemCount() != 0 && gomu.queue.GetCurrentItem() != -1 {
|
|
|
|
a, err := gomu.queue.deleteItem(gomu.queue.GetCurrentItem())
|
|
|
|
if err != nil {
|
|
|
|
logError(err)
|
|
|
|
}
|
2020-08-25 18:17:54 +08:00
|
|
|
|
2021-02-03 10:50:01 +08:00
|
|
|
gomu.queue.pushFront(a)
|
2021-04-03 18:55:54 +08:00
|
|
|
|
2021-04-01 00:07:42 +08:00
|
|
|
if gomu.player.IsRunning() {
|
|
|
|
gomu.player.Skip()
|
|
|
|
} else {
|
|
|
|
gomu.queue.playQueue()
|
|
|
|
}
|
2021-02-03 10:50:01 +08:00
|
|
|
}
|
2020-08-25 18:17:54 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
c.define("toggle_loop", func() {
|
2021-02-27 16:01:48 +08:00
|
|
|
gomu.queue.isLoop = !gomu.queue.isLoop
|
2021-02-03 10:50:01 +08:00
|
|
|
gomu.queue.updateTitle()
|
2020-08-25 18:17:54 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
c.define("shuffle_queue", func() {
|
|
|
|
gomu.queue.shuffle()
|
|
|
|
})
|
|
|
|
|
|
|
|
c.define("queue_search", func() {
|
|
|
|
|
|
|
|
queue := gomu.queue
|
|
|
|
|
2020-08-25 21:11:39 +08:00
|
|
|
audios := make([]string, 0, len(queue.items))
|
|
|
|
for _, file := range queue.items {
|
2021-04-30 15:33:53 +08:00
|
|
|
audios = append(audios, file.Name())
|
2020-08-25 18:17:54 +08:00
|
|
|
}
|
|
|
|
|
2021-02-15 13:56:31 +08:00
|
|
|
searchPopup("Songs", audios, func(selected string) {
|
2020-08-25 18:17:54 +08:00
|
|
|
|
|
|
|
index := 0
|
|
|
|
for i, v := range queue.items {
|
2021-04-30 15:33:53 +08:00
|
|
|
if v.Name() == selected {
|
2020-08-25 18:17:54 +08:00
|
|
|
index = i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
queue.SetCurrentItem(index)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
/* Global */
|
|
|
|
c.define("quit", func() {
|
2021-02-12 10:58:40 +08:00
|
|
|
|
2021-02-18 10:23:15 +08:00
|
|
|
confirmOnExit := anko.GetBool("General.confirm_on_exit")
|
2021-02-12 10:58:40 +08:00
|
|
|
|
|
|
|
if !confirmOnExit {
|
2020-08-25 18:17:54 +08:00
|
|
|
err := gomu.quit(gomu.args)
|
|
|
|
if err != nil {
|
|
|
|
logError(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exitConfirmation(gomu.args)
|
|
|
|
})
|
|
|
|
|
|
|
|
c.define("toggle_pause", func() {
|
2021-02-26 11:18:58 +08:00
|
|
|
gomu.player.TogglePause()
|
2020-08-25 18:17:54 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
c.define("volume_up", func() {
|
2021-02-26 11:18:58 +08:00
|
|
|
v := player.VolToHuman(gomu.player.GetVolume())
|
2020-08-25 18:17:54 +08:00
|
|
|
if v < 100 {
|
2021-02-26 11:18:58 +08:00
|
|
|
vol := gomu.player.SetVolume(0.5)
|
2020-08-25 18:17:54 +08:00
|
|
|
volumePopup(vol)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
c.define("volume_down", func() {
|
2021-02-26 11:18:58 +08:00
|
|
|
v := player.VolToHuman(gomu.player.GetVolume())
|
2020-08-25 18:17:54 +08:00
|
|
|
if v > 0 {
|
2021-02-26 11:18:58 +08:00
|
|
|
vol := gomu.player.SetVolume(-0.5)
|
2020-08-25 18:17:54 +08:00
|
|
|
volumePopup(vol)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
c.define("skip", func() {
|
2021-02-26 11:18:58 +08:00
|
|
|
gomu.player.Skip()
|
2020-08-25 18:17:54 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
c.define("toggle_help", func() {
|
|
|
|
name, _ := gomu.pages.GetFrontPage()
|
|
|
|
|
|
|
|
if name == "help-page" {
|
|
|
|
gomu.pages.RemovePage(name)
|
|
|
|
gomu.app.SetFocus(gomu.prevPanel.(tview.Primitive))
|
|
|
|
} else {
|
|
|
|
helpPopup(gomu.prevPanel)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
c.define("command_search", func() {
|
|
|
|
|
|
|
|
names := make([]string, 0, len(c.commands))
|
|
|
|
for commandName := range c.commands {
|
|
|
|
names = append(names, commandName)
|
|
|
|
}
|
2021-02-15 13:56:31 +08:00
|
|
|
searchPopup("Commands", names, func(selected string) {
|
2020-08-25 18:17:54 +08:00
|
|
|
|
|
|
|
for name, fn := range c.commands {
|
|
|
|
if name == selected {
|
|
|
|
fn()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
2021-01-27 01:10:48 +08:00
|
|
|
|
2021-02-03 10:50:01 +08:00
|
|
|
c.define("forward", func() {
|
2021-02-26 11:18:58 +08:00
|
|
|
if gomu.player.IsRunning() && !gomu.player.IsPaused() {
|
2021-03-30 13:22:21 +08:00
|
|
|
position := gomu.playingBar.getProgress() + 10
|
|
|
|
if position < gomu.playingBar.getFull() {
|
2021-02-26 11:18:58 +08:00
|
|
|
err := gomu.player.Seek(position)
|
2021-02-08 01:06:21 +08:00
|
|
|
if err != nil {
|
2021-03-30 13:22:21 +08:00
|
|
|
errorPopup(err)
|
2021-02-08 01:06:21 +08:00
|
|
|
}
|
2021-03-30 13:22:21 +08:00
|
|
|
gomu.playingBar.setProgress(position)
|
2021-02-03 10:50:01 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
c.define("rewind", func() {
|
2021-02-26 11:18:58 +08:00
|
|
|
if gomu.player.IsRunning() && !gomu.player.IsPaused() {
|
2021-03-30 13:22:21 +08:00
|
|
|
position := gomu.playingBar.getProgress() - 10
|
2021-02-03 10:50:01 +08:00
|
|
|
if position-1 > 0 {
|
2021-02-26 11:18:58 +08:00
|
|
|
err := gomu.player.Seek(position)
|
2021-02-08 01:06:21 +08:00
|
|
|
if err != nil {
|
2021-03-30 13:22:21 +08:00
|
|
|
errorPopup(err)
|
2021-02-08 01:06:21 +08:00
|
|
|
}
|
2021-03-30 13:22:21 +08:00
|
|
|
gomu.playingBar.setProgress(position)
|
2021-02-03 10:50:01 +08:00
|
|
|
} else {
|
2021-02-26 11:18:58 +08:00
|
|
|
err := gomu.player.Seek(0)
|
2021-02-08 01:06:21 +08:00
|
|
|
if err != nil {
|
2021-03-30 13:22:21 +08:00
|
|
|
errorPopup(err)
|
2021-02-08 01:06:21 +08:00
|
|
|
}
|
2021-03-30 13:22:21 +08:00
|
|
|
gomu.playingBar.setProgress(0)
|
2021-02-03 10:50:01 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
c.define("forward_fast", func() {
|
2021-02-26 11:18:58 +08:00
|
|
|
if gomu.player.IsRunning() && !gomu.player.IsPaused() {
|
2021-03-30 13:22:21 +08:00
|
|
|
position := gomu.playingBar.getProgress() + 60
|
|
|
|
if position < gomu.playingBar.getFull() {
|
2021-02-26 11:18:58 +08:00
|
|
|
err := gomu.player.Seek(position)
|
2021-02-08 01:06:21 +08:00
|
|
|
if err != nil {
|
2021-03-30 13:22:21 +08:00
|
|
|
errorPopup(err)
|
2021-02-08 01:06:21 +08:00
|
|
|
}
|
2021-03-30 13:22:21 +08:00
|
|
|
gomu.playingBar.setProgress(position)
|
2021-02-03 10:50:01 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
c.define("rewind_fast", func() {
|
2021-02-26 11:18:58 +08:00
|
|
|
if gomu.player.IsRunning() && !gomu.player.IsPaused() {
|
2021-03-30 13:22:21 +08:00
|
|
|
position := gomu.playingBar.getProgress() - 60
|
2021-02-03 10:50:01 +08:00
|
|
|
if position-1 > 0 {
|
2021-02-26 11:18:58 +08:00
|
|
|
err := gomu.player.Seek(position)
|
2021-02-08 01:06:21 +08:00
|
|
|
if err != nil {
|
2021-03-30 13:22:21 +08:00
|
|
|
errorPopup(err)
|
2021-02-08 01:06:21 +08:00
|
|
|
}
|
2021-03-30 13:22:21 +08:00
|
|
|
gomu.playingBar.setProgress(position)
|
2021-02-03 10:50:01 +08:00
|
|
|
} else {
|
2021-02-26 11:18:58 +08:00
|
|
|
err := gomu.player.Seek(0)
|
2021-02-08 01:06:21 +08:00
|
|
|
if err != nil {
|
2021-03-30 13:22:21 +08:00
|
|
|
errorPopup(err)
|
2021-02-08 01:06:21 +08:00
|
|
|
}
|
2021-03-30 13:22:21 +08:00
|
|
|
gomu.playingBar.setProgress(0)
|
2021-02-03 10:50:01 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
c.define("yank", func() {
|
|
|
|
err := gomu.playlist.yank()
|
2021-01-29 18:20:15 +08:00
|
|
|
if err != nil {
|
2021-03-30 13:22:21 +08:00
|
|
|
errorPopup(err)
|
2021-01-29 18:20:15 +08:00
|
|
|
}
|
2021-02-03 10:50:01 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
c.define("paste", func() {
|
|
|
|
err := gomu.playlist.paste()
|
|
|
|
if err != nil {
|
2021-03-30 13:22:21 +08:00
|
|
|
errorPopup(err)
|
2021-02-03 10:50:01 +08:00
|
|
|
}
|
|
|
|
})
|
2021-01-29 18:20:15 +08:00
|
|
|
|
2021-02-16 13:37:59 +08:00
|
|
|
c.define("repl", func() {
|
|
|
|
replPopup()
|
|
|
|
})
|
|
|
|
|
2021-02-19 14:28:55 +08:00
|
|
|
c.define("edit_tags", func() {
|
|
|
|
audioFile := gomu.playlist.getCurrentFile()
|
2021-03-03 16:56:41 +08:00
|
|
|
err := tagPopup(audioFile)
|
|
|
|
if err != nil {
|
|
|
|
errorPopup(err)
|
|
|
|
}
|
2021-02-23 15:46:51 +08:00
|
|
|
})
|
2021-02-19 14:28:55 +08:00
|
|
|
|
2021-02-23 15:46:51 +08:00
|
|
|
c.define("switch_lyric", func() {
|
|
|
|
gomu.playingBar.switchLyrics()
|
2021-02-19 14:28:55 +08:00
|
|
|
})
|
|
|
|
|
2021-02-23 10:24:23 +08:00
|
|
|
c.define("fetch_lyric", func() {
|
|
|
|
audioFile := gomu.playlist.getCurrentFile()
|
2021-03-09 01:48:01 +08:00
|
|
|
lang := "en"
|
2021-02-23 10:24:23 +08:00
|
|
|
|
2021-03-24 23:50:54 +08:00
|
|
|
var wg sync.WaitGroup
|
|
|
|
wg.Add(1)
|
2021-04-30 15:33:53 +08:00
|
|
|
if audioFile.IsAudioFile() {
|
2021-02-23 10:24:23 +08:00
|
|
|
go func() {
|
2021-03-24 23:50:54 +08:00
|
|
|
err := lyricPopup(lang, audioFile, &wg)
|
|
|
|
if err != nil {
|
|
|
|
errorPopup(err)
|
|
|
|
}
|
|
|
|
}()
|
2021-02-27 23:11:17 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-02-28 13:26:42 +08:00
|
|
|
c.define("fetch_lyric_cn2", func() {
|
2021-02-27 23:11:17 +08:00
|
|
|
audioFile := gomu.playlist.getCurrentFile()
|
2021-03-09 01:48:01 +08:00
|
|
|
lang := "zh-CN"
|
2021-03-24 23:50:54 +08:00
|
|
|
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
wg.Add(1)
|
2021-04-30 15:33:53 +08:00
|
|
|
if audioFile.IsAudioFile() {
|
2021-02-28 13:26:42 +08:00
|
|
|
go func() {
|
2021-03-24 23:50:54 +08:00
|
|
|
err := lyricPopup(lang, audioFile, &wg)
|
|
|
|
if err != nil {
|
|
|
|
errorPopup(err)
|
|
|
|
}
|
2021-02-23 10:24:23 +08:00
|
|
|
}()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-02-25 19:50:52 +08:00
|
|
|
c.define("lyric_delay_increase", func() {
|
2021-02-28 13:26:42 +08:00
|
|
|
err := gomu.playingBar.delayLyric(500)
|
2021-02-25 19:50:52 +08:00
|
|
|
if err != nil {
|
2021-02-28 23:19:42 +08:00
|
|
|
errorPopup(err)
|
2021-02-25 19:50:52 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
c.define("lyric_delay_decrease", func() {
|
2021-02-28 13:26:42 +08:00
|
|
|
err := gomu.playingBar.delayLyric(-500)
|
2021-02-25 19:50:52 +08:00
|
|
|
if err != nil {
|
2021-02-28 23:19:42 +08:00
|
|
|
errorPopup(err)
|
2021-02-25 19:50:52 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-03-15 13:26:51 +08:00
|
|
|
c.define("show_colors", func() {
|
|
|
|
cp := colorsPopup()
|
|
|
|
gomu.pages.AddPage("show-color-popup", center(cp, 95, 40), true, true)
|
|
|
|
gomu.popups.push(cp)
|
|
|
|
})
|
|
|
|
|
2021-02-13 21:00:50 +08:00
|
|
|
for name, cmd := range c.commands {
|
2021-03-21 16:05:23 +08:00
|
|
|
err := gomu.anko.DefineGlobal(name, cmd)
|
2021-02-13 21:00:50 +08:00
|
|
|
if err != nil {
|
2021-02-14 13:45:43 +08:00
|
|
|
logError(err)
|
2021-02-13 21:00:50 +08:00
|
|
|
}
|
|
|
|
}
|
2021-02-19 14:45:20 +08:00
|
|
|
|
2020-08-25 18:17:54 +08:00
|
|
|
}
|