Created
September 30, 2018 07:27
Go program to control VLC playback via HTTP interface (https://superuser.com/questions/1064686/how-to-play-a-movie-listening-to-two-sound-tracks-simultaneously)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
"strconv" | |
) | |
func main() { | |
ports := []int{8080, 8081} | |
c := make(chan bool) | |
for _, port := range ports { | |
go func(p int, c chan bool){ | |
res, err := http.Get("http://:123@192.168.9.2:" + strconv.Itoa(p) + "/requests/status.xml?command=pl_pause") | |
if err != nil { | |
panic(err) | |
} | |
if res.StatusCode != 200 { | |
fmt.Println("Status code: ", res.StatusCode) | |
} | |
c <- true | |
}(port, c) | |
} | |
for range ports { | |
<-c | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment