Git Product home page Git Product logo

go-roku's Introduction

Roku ECP Client

This is a go port of the Roku ECP Client I wrote in Ruby.

TUI Client Usage

Install then run the client

$ go install github.com/shreve/go-roku/cmd/roku

$ roku

This runs an interactive remote control program. By default, it scans the network and connects to the first Roku device it finds. If you'd prefer to hard-code the address, use the environment variable $ROKU_HOST.

Here are some of the key bindings

Key Command
arrow keys navigation
h/j/k/l vi-style navigation
ctrl+up/down volume up/down
ctrl+left/right toggle mute
space bar play/pause
asterisk info/options (asterisk button on physical remote)
esc back/exit
backspace back/exit
enter select
ctrl+q power off
q quit the remote app
ctrl+c quit the remote app
o open app (search interface)

Library Usage

Create a client for a Roku device by passing it's IP to Connect. If you don't know the IP, you can search the network for it with Discover

import "github.com/shreve/go-roku/roku"

var client roku.Client
host := os.Getenv("ROKU_HOST") // 192.168.0.100
if host == "" {
    client, err = roku.Connect(host)
} else {
    client, err = roku.Discover()
}

Once you have a client for a device on the network, you can access the ECP API via various helper functions.

// Turn up the volume for one second
client.Keydown(roku.VolumeUp)
time.Sleep(time.Second)
client.Keyup(roku.VolumeUp)

// Press the power button
client.Keypress(roku.PowerOff)

// Print the name of the device
info := client.DeviceInfo()
fmt.Println(info.FriendlyDeviceName)

// Print the name of the currently running app
app := client.ActiveApp()
fmt.Println(app.Name)

// Launch last app on the list
apps := client.Apps()
client.Launch(apps[len(apps)-1].Id)

Todo

  • Allow retrying discovery rather than quitting in place

Wishlist

  • Add help screen to app
  • Better reporting in app
  • Onscreen keyboard tool
  • Create MPRIS daemon to allow controlling remote device with media keys

go-roku's People

Contributors

shreve avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.