diff --git a/README.MD b/README.MD
index 915c8c5..8bd6334 100644
--- a/README.MD
+++ b/README.MD
@@ -28,6 +28,21 @@ This is the basic json configuration file layout:
# Usage
Drop your sounds into the /sounds. You can play them by sending a GET request to the /v1/play endpoint.
You need to know the base64 encoded file name of the sound you want to play. You can get started by querying /v1/list. It will return a list of all sounds with their respective base64 encoded file name.
-Use that base64 as the `file` parameter in the request.
+Use that base64 as the `file` parameter in the request. The response also includes sample request urls.
+
+## Vanity IDs
+When playing a sound file it will get an incrementing ID. You can use that ID to stop the sound. These are not really predictable and can change at any time. You can also use a vanity ID. This is an integer that you can use to identify the sound. You can set the vanity ID by adding a `id` parameter to the request. The response will include the vanity ID. You can then use that ID to stop the sound.
+
+# Endpoints
+> All endpoints are prefixed with `/v1/`
+
+`GET /list` - Returns a list of all sounds with their respective base64 encoded file name.
+`GET /play` - Plays a sound. The `file` parameter is required. It is the base64 encoded file name of the sound you want to play. Also supports `loop` to be either `true` or `false` (default). It also supports the `id` parameter to set a vanity ID.
+`GET /stop` - Stops a sound. The `id` parameter is required. It is the ID of the sound you want to stop.
+`GET /stopAll` - Stops all sounds.
+`GET /buffer` - Buffers a sound. The `file` parameter is required. It is the base64 encoded file name of the sound you want to buffer.
+`GET /bufferAll` - Buffers all sounds. **Note**: This may take a while. And should probably be run before a show.
+`GET /current` - Returns a list of all currently playing sounds.
+`GET /remaining` - Takes a `id` parameter. Returns the remaining time of the sound with the given ID.
**Note**: The sounds must be in the format `*.mp3`, `*.wav`, `*.flac` or `*.ogg` (`flac` files may take longer time to buffer).
diff --git a/go.mod b/go.mod
index 2c73de7..bf81b28 100644
--- a/go.mod
+++ b/go.mod
@@ -4,6 +4,7 @@ go 1.18
require (
github.com/faiface/beep v1.1.0 // indirect
+ github.com/getsentry/sentry-go v0.19.0 // indirect
github.com/h2non/filetype v1.1.3 // indirect
github.com/hajimehoshi/go-mp3 v0.3.3 // indirect
github.com/hajimehoshi/oto v1.0.1 // indirect
@@ -17,5 +18,6 @@ require (
golang.org/x/exp/shiny v0.0.0-20220428152302-39d4317da171 // indirect
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9 // indirect
golang.org/x/mobile v0.0.0-20220504144722-50dca8fc073d // indirect
- golang.org/x/sys v0.0.0-20220513210249-45d2b4557a2a // indirect
+ golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec // indirect
+ golang.org/x/text v0.3.8 // indirect
)
diff --git a/go.sum b/go.sum
index c449b99..0d0b8c6 100644
--- a/go.sum
+++ b/go.sum
@@ -5,6 +5,8 @@ github.com/faiface/beep v1.1.0 h1:A2gWP6xf5Rh7RG/p9/VAW2jRSDEGQm5sbOb38sf5d4c=
github.com/faiface/beep v1.1.0/go.mod h1:6I8p6kK2q4opL/eWb+kAkk38ehnTunWeToJB+s51sT4=
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
github.com/gdamore/tcell v1.3.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM=
+github.com/getsentry/sentry-go v0.19.0 h1:BcCH3CN5tXt5aML+gwmbFwVptLLQA+eT866fCO9wVOM=
+github.com/getsentry/sentry-go v0.19.0/go.mod h1:y3+lGEFEFexZtpbG1GUE2WD/f9zGyKYwpEqryTOC/nE=
github.com/go-audio/audio v1.0.0/go.mod h1:6uAu0+H2lHkwdGsAY+j2wHPNPpPoeg5AaEFh9FlA+Zs=
github.com/go-audio/riff v1.0.0/go.mod h1:l3cQwc85y79NQFCRB7TiPoNiaijp6q8Z0Uv38rVG498=
github.com/go-audio/wav v1.0.0/go.mod h1:3yoReyQOsiARkvPl3ERCi8JFjihzG6WhjYpZCf5zAWE=
@@ -70,9 +72,13 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220513210249-45d2b4557a2a h1:N2T1jUrTQE9Re6TFF5PhvEHXHCguynGhKjWVsIUt5cY=
golang.org/x/sys v0.0.0-20220513210249-45d2b4557a2a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec h1:BkDtF2Ih9xZ7le9ndzTA7KJow28VbQW3odyk/8drmuI=
+golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY=
+golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
diff --git a/soundr.go b/soundr.go
index 7e54a0b..edcbbce 100644
--- a/soundr.go
+++ b/soundr.go
@@ -9,6 +9,7 @@ import (
"os"
"github.com/faiface/beep"
+ "github.com/getsentry/sentry-go"
)
type playback struct {
@@ -34,7 +35,8 @@ type streamBuf struct {
}
type Configuration struct {
- Port int
+ Port int
+ AllowSentry bool
}
var playbacks map[int]playback
@@ -68,7 +70,8 @@ func main() {
fmt.Println("Writing to conf.json")
// Write the default config to the file
json.NewEncoder(file).Encode(Configuration{
- Port: 8080,
+ Port: 8080,
+ AllowSentry: true,
})
fmt.Println("Wrote to conf.json")
}
@@ -78,6 +81,18 @@ func main() {
configuration := Configuration{}
err := decoder.Decode(&configuration)
+ if configuration.AllowSentry {
+ err := sentry.Init(sentry.ClientOptions{
+ Dsn: "https://0eae4896cb23446b99a8a5b9f9da75f1@sentry.thegreydiamond.de/8",
+ // Enable printing of SDK debug messages.
+ // Useful when getting started or trying to figure something out.
+ // Debug: true,
+ })
+ if err != nil {
+ log.Fatalf("sentry.Init: %s", err)
+ }
+ }
+
if err != nil {
fmt.Println("error:", err)
}