Skip to content

Commit

Permalink
Audio notification tone fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mivl committed Oct 29, 2018
1 parent 50c9578 commit 07ac284
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 44 deletions.
Binary file removed assets/notify.mp3
Binary file not shown.
Binary file added assets/notify.wav
Binary file not shown.
19 changes: 18 additions & 1 deletion cmd/jira-notificator-gui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

const (
notificationSound = "assets/notify.mp3"
notificationSound = "assets/notify.wav"
icon = "assets/icon.ico"
interval = 15
)
Expand Down Expand Up @@ -54,6 +54,11 @@ func makeBasicControlsPage() ui.Control {

button := ui.NewButton("Přihlásit se")
button.OnClicked(func(*ui.Button) {
if host.Text() == "" || username.Text() == "" || password.Text() == "" {
ui.MsgBoxError(mainwin, "Chyba", "Vyplňte všechny údaje")
return
}

host.Disable()
username.Disable()
password.Disable()
Expand All @@ -64,6 +69,10 @@ func makeBasicControlsPage() ui.Control {
if err != nil {
ui.QueueMain(func() {
ui.MsgBoxError(window, "Chyba", err.Error())
host.Enable()
username.Enable()
password.Enable()
button.Enable()
})
return
}
Expand All @@ -72,6 +81,10 @@ func makeBasicControlsPage() ui.Control {
if err != nil {
ui.QueueMain(func() {
ui.MsgBoxError(window, "Chyba", err.Error())
host.Enable()
username.Enable()
password.Enable()
button.Enable()
})
return
}
Expand All @@ -83,6 +96,10 @@ func makeBasicControlsPage() ui.Control {
if err != nil {
ui.QueueMain(func() {
ui.MsgBoxError(window, "Chyba", err.Error())
host.Enable()
username.Enable()
password.Enable()
button.Enable()
})
return
}
Expand Down
35 changes: 0 additions & 35 deletions pkg/jira/audio.go

This file was deleted.

19 changes: 11 additions & 8 deletions pkg/jira/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package jira

import (
"github.com/gen2brain/beeep"
"github.com/hajimehoshi/oto"
"github.com/pkg/errors"
"log"
"time"
)
Expand Down Expand Up @@ -33,14 +35,14 @@ func FetchNewNotifications(c Client, data NotificationData) error {
channel := make(chan []Notification)
finished := make(chan bool)

player, err := NewPlayer(data.Sound)
player, err := oto.NewPlayer(44100, 2, 2, 40000)
if err != nil {
return err
return errors.Wrap(err, "Chyba při inicializaci zvukového zařízení")
}

worker, err := NewWorker(c, channel, finished)
if err != nil {
return err
return errors.Wrap(err, "Chyba navázání připojení na data notifikací")
}

notificator := &notificator{beeep.Alert}
Expand All @@ -51,16 +53,17 @@ func FetchNewNotifications(c Client, data NotificationData) error {
case notifications := <-channel:
log.Println(data.Text)

if err := player.Play(); err != nil {
return err
_, err := player.Write(data.Sound)
if err != nil {
return errors.Wrap(err, "Chyba při přehrávání tónu notifikace")
}

err := notificator.notify(notifications)
err = notificator.notify(notifications)
if err != nil {
return err
return errors.Wrap(err, "Chyba při vytváření notifikace")
}
case <-finished:
return worker.e
return errors.Wrap(worker.e, "Chyba při provádění aktualizace dat")
}
}
}

0 comments on commit 07ac284

Please sign in to comment.