mirror of https://bitbucket.org/ausocean/av.git
cmd/audio-player/looper: use a command line flag for choosing audio file path
This commit is contained in:
parent
8cbc7e700c
commit
c5fb58e70c
|
@ -28,6 +28,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"flag"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -38,8 +39,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Constants.
|
// Command line flags.
|
||||||
const soundFile = "/home/pi/48khz.wav"
|
var soundFilePtr = flag.String("path", "", "Location of sound file")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
// Logging constants.
|
// Logging constants.
|
||||||
const (
|
const (
|
||||||
|
@ -71,7 +73,7 @@ func main() {
|
||||||
numPlays++
|
numPlays++
|
||||||
log.Log(logger.Debug, "playing audio", "play number", numPlays)
|
log.Log(logger.Debug, "playing audio", "play number", numPlays)
|
||||||
|
|
||||||
cmd := exec.Command(audioCmd, soundFile)
|
cmd := exec.Command(audioCmd, *soundFilePtr)
|
||||||
|
|
||||||
var stdoutBuf, stderrBuf bytes.Buffer
|
var stdoutBuf, stderrBuf bytes.Buffer
|
||||||
stdoutIn, _ := cmd.StdoutPipe()
|
stdoutIn, _ := cmd.StdoutPipe()
|
||||||
|
|
Loading…
Reference in New Issue