increase volume limit to 100

This commit is contained in:
raziman 2020-07-24 15:47:36 +08:00
parent dbb9fc6940
commit 6385abf459
3 changed files with 7 additions and 10 deletions

View File

@ -43,7 +43,6 @@ func newPlayer() *Player {
func (p *Player) run(currSong *AudioFile) error {
p.isSkipped = make(chan bool, 1)
f, err := os.Open(currSong.path)
if err != nil {
@ -109,9 +108,7 @@ func (p *Player) run(currSong *AudioFile) error {
// sets the volume of previous player
volume.Volume += p.volume
p._volume = volume
speaker.Play(p._volume)
position := func() time.Duration {
@ -212,7 +209,7 @@ func (p *Player) setVolume(v float64) float64 {
defer func() {
// saves the volume
volume := int(p.volume*10) + 50
volume := int(p.volume*10) + 100
viper.Set("volume", volume)
}()

View File

@ -166,13 +166,13 @@ func timedPopup(
// Shows popup for the current volume
func volumePopup(volume float64) {
vol := int(volume*10) + 50
vol := int(volume*10) + 100
progress := fmt.Sprintf("\n%d |%s%s| %s",
vol,
strings.Repeat("█", vol),
strings.Repeat("-", 50-vol),
"50",
strings.Repeat("-", 100-vol),
"100",
)
timedPopup(" Volume ", progress, getPopupTimeout(), 0, 0)

View File

@ -176,14 +176,14 @@ func start(application *tview.Application, args Args) {
gomu.player.togglePause()
case '+':
v := int(gomu.player.volume*10) + 50
if v < 50 {
v := int(gomu.player.volume*10) + 100
if v < 100 {
vol := gomu.player.setVolume(0.5)
volumePopup(vol)
}
case '-':
v := int(gomu.player.volume*10) + 50
v := int(gomu.player.volume*10) + 100
if v > 0 {
vol := gomu.player.setVolume(-0.5)
volumePopup(vol)