roku-ecp
Version:
A Node package designed to control Roku devices using TypeScript
136 lines (135 loc) • 5.39 kB
TypeScript
import { Dim2Values, Dim3Values, InputOptions, Keys, LaunchOptions, MediaPlayerInfo, RokuActiveChannel, RokuApp, RokuAppInfo, RokuChannel, RokuDevice, SearchOptions, SensorType, TouchOp } from "./types";
import { App } from "./app";
export declare class Roku {
static discover: (timeout?: number) => Promise<import("./types").SSDPDevice[]>;
static keys: typeof Keys;
location: string;
private queue;
private processing;
toString: () => string;
private execute;
/**
* Initializes a new Roku given its location
* @param {string} location The URL of the device
*/
constructor(location: string);
/**
* Sends a GET request
* @param {string} path Request URL
* @param {{}} params Request parameters
*/
get: (path: string, params?: {}) => Promise<Response>;
/**
* Sends a POST request with no body
* @param {string} path Request URL
* @param {{}} params Request parameters
*/
post: (path: string, params?: {}) => Promise<Response>;
/**
* Enables an external client to drive the Roku Search UI to find and (optionally) launch content from an available provider.
* @param {{}} options Search parameters (keyword required)
*/
search: (options: SearchOptions) => Promise<Response>;
/**
* Equivalent to pressing down and releasing the identified remote control key. Can accept keyboard alphanumeric characters when a keyboard screen is active (see type)
* @param {string[]} keys A list of keys to press
*/
press: (...keys: (Keys | string)[]) => void;
/**
* Equivalent to pressing the identified remote control key
* @param {string} key Key to be pressed (case insensitive)
*/
keyDown: (key: Keys) => Promise<Response>;
/**
* Equivalent to releasing the identified remote control key
* @param {string} key Key to be released (case insensitive)
*/
keyUp: (key: Keys) => Promise<Response>;
/**
* Launches the identified app. Can accept launch parameters for deep linking.
* @param {number} id The id of the app
* @param {{}} options Launch parameters (for deep linking)
*/
launch: (id: number | "dev", options?: LaunchOptions) => Promise<Response>;
/**
* Sends custom events to the current application
* @param {{}} options Input parameters
*/
input: (options: InputOptions) => Promise<Response>;
/**
* Retrieves information about the device
* @returns {{}} Device details
*/
info: () => Promise<RokuDevice>;
/**
* Retrieves information about the current application
* @returns {{}} App details
*/
activeApp: () => Promise<RokuApp>;
/**
* Retrieves information about the device's applications
* @returns {{}[]} An array of app details
*/
apps: () => Promise<RokuApp[]>;
/**
* Retrieves information about the currently tuned TV channel
* @remarks Restricted to Roku TV devices that support live TV
* @returns {{}} Channel details
*/
activeChannel: () => Promise<RokuActiveChannel>;
/**
* Retrieves information about the TV channel / line-up available for viewing in the TV tuner UI
* @remarks Restricted to Roku TV devices that support live TV
* @returns {{}[]} An array of channel details
*/
channels: () => Promise<RokuChannel[]>;
/**
* Launches the identified channel
* @remarks Restricted to Roku TV devices that support live TV
* @param {number} id The channel number
*/
launchChannel: (id: number) => Promise<Response>;
/**
* Wait between key presses
* @param {number} ms Delay time in milliseconds
*/
wait: (ms: number) => Promise<boolean>;
/**
* Exits the current channel, and launches the Channel Store details screen of the identified app.
* @param {number} id The id of the app
*/
install: (id: number) => Promise<Response>;
/**
* Types alphanumeric characters, provided a keyboard screen is active
* @param {string} input Text to be typed
*/
type: (input: string) => void;
/**
* Sends custom sensor events to the device
* @param {"acceleration" | "orientation" | "rotation" | "magnetic"} input The sensor type
* @param {{x: number, y: number, z: number}} values The sensor input values
*/
sensor: (input: SensorType, values: Dim3Values) => Promise<Response>;
/**
* Sends custom touch or multi-touch events to the device
* @param {{x: number, y: number}} values The touch input values
* @param {"up" | "down" | "press" | "move" | "cancel"} op The touch operation
*/
touch: (values: Dim2Values, op?: TouchOp) => Promise<Response>;
/**
* Creates a new instance of the `App` class
* @param {{}} appInfo App information (id required)
* @returns {App} The new App
*/
app: (appInfo: RokuAppInfo) => App;
/**
* Returns an icon corresponding to the identified application
* @param {number} id The id of the app
*/
icon: (id: number) => Promise<Response>;
/**
* Retrieves information about the current stream segment and position of the content being played, the running time of the content, audio format, and buffering
* @returns {{}} Media player details
*/
mediaPlayer: () => Promise<MediaPlayerInfo>;
}