Documentation ¶
Index ¶
- Variables
- type App
- type Command
- type Input
- type Message
- type MessageType
- type Payload
- type Service
- type ServiceList
- type TV
- func (tv *TV) AppStatus(app string) (*App, error)
- func (tv *TV) AuthoriseClientKey(key string) error
- func (tv *TV) AuthorisePrompt() (string, error)
- func (tv *TV) ChannelDown() error
- func (tv *TV) ChannelList() (Message, error)
- func (tv *TV) ChannelUp() error
- func (tv *TV) Close() error
- func (tv *TV) CloseApp(app string) error
- func (tv *TV) Command(uri Command, req Payload) (Message, error)
- func (tv *TV) CurrentApp() (*App, error)
- func (tv *TV) CurrentChannel() (Message, error)
- func (tv *TV) CurrentProgram() (Message, error)
- func (tv *TV) FastForward() error
- func (tv *TV) GetVolume() (*Volume, error)
- func (tv *TV) KeyBack() error
- func (tv *TV) KeyDown() error
- func (tv *TV) KeyHome() error
- func (tv *TV) KeyLeft() error
- func (tv *TV) KeyOk() (Message, error)
- func (tv *TV) KeyRight() error
- func (tv *TV) KeyUp() error
- func (tv *TV) LaunchApp(app string) error
- func (tv *TV) MessageHandler() (err error)
- func (tv *TV) Mute() error
- func (tv *TV) Notification(m string) error
- func (tv *TV) OpenApp(app string) error
- func (tv *TV) Pause() error
- func (tv *TV) Play() error
- func (tv *TV) Rewind() error
- func (tv *TV) ServiceList() (*ServiceList, error)
- func (tv *TV) SetVolume(v int) error
- func (tv *TV) Shutdown() error
- func (tv *TV) Stop() error
- func (tv *TV) Unmute() error
- func (tv *TV) VolumeDown() error
- func (tv *TV) VolumeStatus() (*Volume, error)
- func (tv *TV) VolumeUp() error
- type Volume
Constants ¶
This section is empty.
Variables ¶
var ( // Protocol is the protocol used to connect to the TV. Protocol = "wss" // Port is the port used to connect to the TV. Port = 3001 )
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct { ReturnValue bool AppID string WindowID string ProcessID string Running bool Visible bool }
App represents an applications in the TVs responses.
type Command ¶
type Command string
Command is the type used by tv.Command to interact with the TV.
const ( // APIServiceListCommand lists the API services available on the TV. APIServiceListCommand Command = "ssap://api/getServiceList" // ApplicationManagerForegroundAppCommand returns information about the forgeground app. ApplicationManagerForegroundAppCommand Command = "ssap://com.webos.applicationManager/getForegroundAppInfo" // AudioGetVolumeCommand returns information about the TV's configured audio output volume. AudioGetVolumeCommand Command = "ssap://audio/getVolume" // AudioSetVolumeCommand sets the TV's configured audio output volume. AudioSetVolumeCommand Command = "ssap://audio/setVolume" // AudioVolumeDownCommand decrements the TV's configured audio output volume. AudioVolumeDownCommand Command = "ssap://audio/volumeDown" // AudioVolumeStatusCommand returns information about the TV's configured audio output volume. // Same as AudioGetVolumeCommand. AudioVolumeStatusCommand Command = "ssap://audio/getVolume" // AudioVolumeUpCommand increments the TV's configured audio output volume. AudioVolumeUpCommand Command = "ssap://audio/volumeUp" // AudioVolumeSetMuteCommand sets/toggles muting the TV's configured audio output. AudioVolumeSetMuteCommand Command = "ssap://audio/setMute" // MediaControlFastForwardCommand fast forwards the current media. MediaControlFastForwardCommand Command = "ssap://media.controls/fastForward" // MediaControlPauseCommand pauses the current media. MediaControlPauseCommand Command = "ssap://media.controls/pause" // MediaControlPlayCommand plays or resumes the current media. MediaControlPlayCommand Command = "ssap://media.controls/play" // MediaControlRewindCommand rewinds the current media. MediaControlRewindCommand Command = "ssap://media.controls/rewind" // MediaControlStopCommand stops the current media. MediaControlStopCommand Command = "ssap://media.controls/stop" // SystemLauncherCloseCommand closes a given application. SystemLauncherCloseCommand Command = "ssap://system.launcher/close" // SystemLauncherGetAppStateCommand returns information about the given application state. SystemLauncherGetAppStateCommand Command = "ssap://system.launcher/getAppState" // SystemLauncherLaunchCommand launches the given application. SystemLauncherLaunchCommand Command = "ssap://system.launcher/launch" // SystemLauncherOpenCommand opens a previously launched application. SystemLauncherOpenCommand Command = "ssap://system.launcher/open" // SystemNotificationsCreateToastCommand creates a "toast" notification. SystemNotificationsCreateToastCommand Command = "ssap://system.notifications/createToast" // SystemTurnOffCommand turns the TV off. SystemTurnOffCommand Command = "ssap://system/turnOff" // TVChannelDownCommand changes the channel down. TVChannelDownCommand Command = "ssap://tv/channelDown" // TVChannelListCommand returns information about the available channels. TVChannelListCommand Command = "ssap://tv/getChannelList" // TVChannelUpCommand changes the channel up. TVChannelUpCommand Command = "ssap://tv/channelUp" // TVCurrentChannelCommand returns information about the current channel. TVCurrentChannelCommand Command = "ssap://tv/getCurrentChannel" // TVCurrentChannelProgramCommand returns information about the current program playing on // the current channel. TVCurrentChannelProgramCommand Command = "ssap://tv/getChannelProgramInfo" GetPointerInputSocketCommand Command = "ssap://com.webos.service.networkinput/getPointerInputSocket" KeyEnterCommand Command = "ssap://com.webos.service.ime/sendEnterKey" )
type Input ¶
type Input struct {
// contains filtered or unexported fields
}
type Message ¶
type Message struct { Type MessageType `json:"type,omitempty"` ID string `json:"id,omitempty"` URI Command `json:"uri,omitempty"` Payload Payload `json:"payload,omitempty"` Error string `json:"error,omitempty"` }
Message represents the JSON message format used in request and responses to and from the TV.
type MessageType ¶
type MessageType string
MessageType is the type sent to and returned by the TV in the `type` field.
const ( // ErrorMessageType is returned by the TV when an error has occurred. ErrorMessageType MessageType = "error" // RegisterMessageType is sent to the TV in a registration request. RegisterMessageType MessageType = "register" // RegisteredMessageType is returned by the TV in response to a registration request. RegisteredMessageType MessageType = "registered" // RequestMessageType is sent to the TV when issuing Commands. RequestMessageType MessageType = "request" // ResponseMessageType is returned by the TV in response to a request. ResponseMessageType MessageType = "response" )
type Payload ¶
type Payload map[string]interface{}
Payload represents the Payload contained in the Message body.
type ServiceList ¶
type ServiceList struct {
Services []Service
}
ServiceList represents an array of Service types in the TVs responses.
type TV ¶
type TV struct {
// contains filtered or unexported fields
}
TV represents the TV. It contains the websocket connection, necessary channels used for communication and methods used for interaction with the TV.
func (*TV) AuthoriseClientKey ¶
AuthoriseClientKey autorises with the TV using an existing client key.
func (*TV) AuthorisePrompt ¶
AuthorisePrompt autorises with the TV using the PROMPT method.
func (*TV) ChannelDown ¶
ChannelDown decrements the current channel.
func (*TV) ChannelList ¶
ChannelList returns information about available channels.
@todo implement a ChannelList type. This doesn't work on my TV.
func (*TV) CurrentApp ¶
CurrentApp returns information about the current app.
func (*TV) CurrentChannel ¶
CurrentChannel returns information about the current channel.
@todo implement a Channel type. This doesn't work on my TV.
func (*TV) CurrentProgram ¶
CurrentProgram returns information about the current program shown on the CurrentChannel.
@todo implement a Program type. This doesn't work on my TV.
func (*TV) FastForward ¶
FastForward fast forwards the current media.
func (*TV) MessageHandler ¶
MessageHandler listens to the TVs websocket and reads responses. Responses are read into a Message type and added to appropriate channel based on the Message.ID.
func (*TV) Notification ¶
Notification creates a "toast" notification.
func (*TV) ServiceList ¶
func (tv *TV) ServiceList() (*ServiceList, error)
ServiceList returns information about the available services.
func (*TV) VolumeDown ¶
VolumeDown decrements the audio output volume.
func (*TV) VolumeStatus ¶
VolumeStatus returns information about the audio output volume.