-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.go
63 lines (53 loc) · 1.15 KB
/
app.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"context"
"github.com/wailsapp/wails/v2/pkg/runtime"
"toolow/volume"
)
// App struct
type App struct {
ctx context.Context
v volume.Volume
}
// NewApp creates a new App application struct
func NewApp() *App {
return &App{}
}
// startup is called when the app starts. The context is saved
// so we can call the runtime methods
func (a *App) startup(ctx context.Context) {
a.ctx = ctx
a.v = volume.NewVolume(a.ctx)
}
// Get path to video file
func (a *App) Videofile() string {
video, err := runtime.OpenFileDialog(a.ctx, runtime.OpenDialogOptions{
Title: "Select File",
Filters: []runtime.FileFilter{
{
DisplayName: "Videos (*.mov;*.mp4)",
Pattern: "*.mov;*.mp4",
},
},
})
if err != nil {
return err.Error()
}
return video
}
// Detect volume levels on video
func (a *App) Volume(video string) (volume.Volume, error) {
v, err := a.v.Volumedetect(video)
if err != nil {
return volume.Volume{}, err
}
return v, nil
}
// Normalize audio on the video
func (a *App) Normalize(video string) (volume.Volume, error) {
v, err := a.v.Lufs(video)
if err != nil {
return volume.Volume{}, err
}
return v, nil
}