go-caster
testing
forked from github.com/vishen/go-chromecast
goal
- make a easy to use library for chromecast with documentation and examples
TODOs
- remove everything that is not needed to control a chromecast
- error handling
- fix race conditions
- remove more stuff
removed libs
- github.com/mitchellh/go-homedir
- github.com/pkg/errors
- github.com/sirupsen/logrus
- github.com/h2non/filetype
use
Discover cast devices
package main
import (
"context"
"fmt"
"log"
"net"
"strings"
"time"
"github.com/ConfusedManbird/go-caster/dns"
)
func discoverCastDevices(i *net.Interface) {
ctx, timeout := context.WithTimeout(context.Background(), time.Duration(1)*time.Second)
entries, err := dns.DiscoverCastDNSEntries(ctx, i)
if err != nil {
log.Fatalf("ERROR:: ::%v\n", err)
}
defer timeout()
for entry := range entries {
fmt.Printf("Device: %s\n Name: %s\n IP: %s\n Port: %d\n", entry.GetUUID(), entry.GetName(), entry.GetAddr(), entry.GetPort())
}
}
func main() {
iFaces, _ := net.Interfaces()
for _, iFace := range iFaces {
addrs, _ := iFace.Addrs()
for _, addr := range addrs {
if strings.Contains(addr.String(), "/24") {
discoverCastDevices(&iFace)
}
}
}
}
cast "big buck bunny"
package main
import (
"github.com/ConfusedManbird/go-caster/application"
"log"
)
func main() {
uri := "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
castAddress := "10.0.0.23"
app := application.NewApplication()
if err := app.Start(castAddress, 8009); err != nil {
log.Printf("ERROR::unable to start application::%v\n", err)
return
}
if err := app.LoadApp("CC1AD845", uri); err != nil {
log.Printf("ERROR::app.LoadApp()::%v\n", err)
}
}