Documentation
¶
Index ¶
- Constants
- Variables
- type Application
- type ApplicationControl
- func (a *ApplicationControl) Close(ctx context.Context, appID string) error
- func (a *ApplicationControl) GetForegroundApp(ctx context.Context) (string, error)
- func (a *ApplicationControl) Launch(ctx context.Context, appID string, contentID string, ...) error
- func (a *ApplicationControl) ListApps(ctx context.Context) ([]Application, error)
- type AudioOutputSource
- type ChannelInfo
- type Client
- func (c *Client) Close() error
- func (c *Client) Connect() error
- func (c *Client) Register(ctx context.Context, store map[string]string) (<-chan RegistrationStatus, <-chan error)
- func (c *Client) Request(ctx context.Context, uri string, payload interface{}) (*Message, error)
- func (c *Client) SendMessage(ctx context.Context, id string, requestType string, uri string, ...) (<-chan *Message, string, error)
- func (c *Client) Subscribe(uri string, callback func(json.RawMessage)) (string, error)
- func (c *Client) URL() string
- func (c *Client) Unsubscribe(id string) error
- type Control
- type DiscoverOption
- type DiscoverOptions
- type InputControl
- func (i *InputControl) Back() error
- func (i *InputControl) Blue() error
- func (i *InputControl) Button(name string) error
- func (i *InputControl) ChannelDown() error
- func (i *InputControl) ChannelUp() error
- func (i *InputControl) Click() error
- func (i *InputControl) ConnectInput(ctx context.Context) error
- func (i *InputControl) Dash() error
- func (i *InputControl) Delete(ctx context.Context, count int) error
- func (i *InputControl) DisconnectInput() error
- func (i *InputControl) Down() error
- func (i *InputControl) Enter(ctx context.Context) error
- func (i *InputControl) Exit() error
- func (i *InputControl) FastForward() error
- func (i *InputControl) Green() error
- func (i *InputControl) Home() error
- func (i *InputControl) Info() error
- func (i *InputControl) Left() error
- func (i *InputControl) Menu() error
- func (i *InputControl) Move(dx, dy int, drag int) error
- func (i *InputControl) Mute() error
- func (i *InputControl) OK() error
- func (i *InputControl) Pause() error
- func (i *InputControl) Play() error
- func (i *InputControl) Red() error
- func (i *InputControl) Rewind() error
- func (i *InputControl) Right() error
- func (i *InputControl) Scroll(dx, dy int) error
- func (i *InputControl) Stop() error
- func (i *InputControl) Type(ctx context.Context, text string) error
- func (i *InputControl) Up() error
- func (i *InputControl) VolumeDown() error
- func (i *InputControl) VolumeUp() error
- func (i *InputControl) Yellow() error
- type InputSource
- type MediaControl
- func (m *MediaControl) FastForward(ctx context.Context) error
- func (m *MediaControl) GetAudioOutput(ctx context.Context) (*AudioOutputSource, error)
- func (m *MediaControl) GetVolume(ctx context.Context) (*VolumeInfo, error)
- func (m *MediaControl) Mute(ctx context.Context, mute bool) error
- func (m *MediaControl) Pause(ctx context.Context) error
- func (m *MediaControl) Play(ctx context.Context) error
- func (m *MediaControl) Rewind(ctx context.Context) error
- func (m *MediaControl) SetAudioOutput(ctx context.Context, output string) error
- func (m *MediaControl) SetVolume(ctx context.Context, volume int) error
- func (m *MediaControl) Stop(ctx context.Context) error
- func (m *MediaControl) SubscribeVolume(callback func(*VolumeInfo)) (string, error)
- func (m *MediaControl) VolumeDown(ctx context.Context) error
- func (m *MediaControl) VolumeUp(ctx context.Context) error
- type Message
- type Option
- type RegistrationStatus
- type SWInformation
- type SourceControl
- type SystemControl
- func (s *SystemControl) Info(ctx context.Context) (*SWInformation, error)
- func (s *SystemControl) Notify(ctx context.Context, message string, iconBytes []byte, iconExt string) error
- func (s *SystemControl) PowerOff(ctx context.Context) error
- func (s *SystemControl) ScreenOff(ctx context.Context) error
- func (s *SystemControl) ScreenOn(ctx context.Context) error
- type TvControl
- func (t *TvControl) ChannelDown(ctx context.Context) error
- func (t *TvControl) ChannelList(ctx context.Context) ([]ChannelInfo, error)
- func (t *TvControl) ChannelUp(ctx context.Context) error
- func (t *TvControl) GetCurrentChannel(ctx context.Context) (*ChannelInfo, error)
- func (t *TvControl) SetChannel(ctx context.Context, channelID string) error
- type VolumeInfo
Constants ¶
const ( // DefaultHandshakeTimeout is the default timeout for websocket handshake. DefaultHandshakeTimeout = 10 * time.Second // DefaultWriteWait is the default time to wait for a message to be written. DefaultWriteWait = 10 * time.Second )
const (
// SSDPService is the SSDP service type for WebOS TVs.
SSDPService = "urn:schemas-upnp-org:device:MediaRenderer:1"
)
const (
Signature = "eyJhbGdvcml0aG0iOiJSU0EtU0hBMjU2Iiwia2V5SWQiOiJ0ZXN0LXNpZ25pbm" +
"ctY2VydCIsInNpZ25hdHVyZVZlcnNpb24iOjF9.hrVRgjCwXVvE2OOSpDZ58hR" +
"+59aFNwYDyjQgKk3auukd7pcegmE2CzPCa0bJ0ZsRAcKkCTJrWo5iDzNhMBWRy" +
"aMOv5zWSrthlf7G128qvIlpMT0YNY+n/FaOHE73uLrS/g7swl3/qH/BGFG2Hu4" +
"RlL48eb3lLKqTt2xKHdCs6Cd4RMfJPYnzgvI4BNrFUKsjkcu+WD4OO2A27Pq1n" +
"50cMchmcaXadJhGrOqH5YmHdOCj5NSHzJYrsW0HPlpuAx/ECMeIZYDh6RMqaFM" +
"2DXzdKX9NmmyqzJ3o/0lkk/N97gfVRLW5hA29yeAwaCViZNCP8iC9aO0q9fQoj" +
"oa7NQnAtw=="
)
Variables ¶
var ( ErrConnectionClosed = errors.New("connection closed") ErrTimeout = errors.New("timeout") ErrInvalidResponse = errors.New("invalid response from TV") )
var RegistrationPayload = map[string]interface{}{ "forcePairing": false, "manifest": map[string]interface{}{ "appVersion": "1.1", "manifestVersion": 1, "permissions": []string{ "LAUNCH", "LAUNCH_WEBAPP", "APP_TO_APP", "CLOSE", "TEST_OPEN", "TEST_PROTECTED", "CONTROL_AUDIO", "CONTROL_DISPLAY", "CONTROL_INPUT_JOYSTICK", "CONTROL_INPUT_MEDIA_RECORDING", "CONTROL_INPUT_MEDIA_PLAYBACK", "CONTROL_INPUT_TV", "CONTROL_POWER", "READ_APP_STATUS", "READ_CURRENT_CHANNEL", "READ_INPUT_DEVICE_LIST", "READ_NETWORK_STATE", "READ_RUNNING_APPS", "READ_TV_CHANNEL_LIST", "WRITE_NOTIFICATION_TOAST", "READ_POWER_STATE", "READ_COUNTRY_INFO", "READ_SETTINGS", "CONTROL_TV_SCREEN", "CONTROL_TV_STANBY", "CONTROL_FAVORITE_GROUP", "CONTROL_USER_INFO", "CHECK_BLUETOOTH_DEVICE", "CONTROL_BLUETOOTH", "CONTROL_TIMER_INFO", "STB_INTERNAL_CONNECTION", "CONTROL_RECORDING", "READ_RECORDING_STATE", "WRITE_RECORDING_LIST", "READ_RECORDING_LIST", "READ_RECORDING_SCHEDULE", "WRITE_RECORDING_SCHEDULE", "READ_STORAGE_DEVICE_LIST", "READ_TV_PROGRAM_INFO", "CONTROL_BOX_CHANNEL", "READ_TV_ACR_AUTH_TOKEN", "READ_TV_CONTENT_STATE", "READ_TV_CURRENT_TIME", "ADD_LAUNCHER_CHANNEL", "SET_CHANNEL_SKIP", "RELEASE_CHANNEL_SKIP", "CONTROL_CHANNEL_BLOCK", "DELETE_SELECT_CHANNEL", "CONTROL_CHANNEL_GROUP", "SCAN_TV_CHANNELS", "CONTROL_TV_POWER", "CONTROL_WOL", }, "signatures": []map[string]interface{}{ { "signature": Signature, "signatureVersion": 1, }, }, "signed": map[string]interface{}{ "appId": "com.lge.test", "created": "20140509", "localizedAppNames": map[string]string{ "": "LG Remote App", "ko-KR": "리모컨 앱", "zxx-XX": "ЛГ Rэмotэ AПП", }, "localizedVendorNames": map[string]string{ "": "LG Electronics", }, "permissions": []string{ "TEST_SECURE", "CONTROL_INPUT_TEXT", "CONTROL_MOUSE_AND_KEYBOARD", "READ_INSTALLED_APPS", "READ_LGE_SDX", "READ_NOTIFICATIONS", "SEARCH", "WRITE_SETTINGS", "WRITE_SETTINGS", "WRITE_NOTIFICATION_ALERT", "CONTROL_POWER", "READ_CURRENT_CHANNEL", "READ_RUNNING_APPS", "READ_UPDATE_INFO", "UPDATE_FROM_REMOTE_APP", "READ_LGE_TV_INPUT_EVENTS", "READ_TV_CURRENT_TIME", }, "serial": "2f930e2d2cfe083771f68e4fe7bb07", "vendorId": "com.lge", }, }, "pairingType": "PROMPT", }
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application struct {
ID string `json:"id"`
Title string `json:"title"`
Icon string `json:"icon"`
Data map[string]interface{} `json:"-"`
}
Application represents a WebOS application.
func (Application) String ¶
func (a Application) String() string
type ApplicationControl ¶
type ApplicationControl struct {
Control
}
ApplicationControl provides methods to manage applications.
func (*ApplicationControl) Close ¶
func (a *ApplicationControl) Close(ctx context.Context, appID string) error
func (*ApplicationControl) GetForegroundApp ¶ added in v0.1.0
func (a *ApplicationControl) GetForegroundApp(ctx context.Context) (string, error)
func (*ApplicationControl) ListApps ¶
func (a *ApplicationControl) ListApps(ctx context.Context) ([]Application, error)
type AudioOutputSource ¶
type AudioOutputSource struct {
Source string `json:"soundOutput"`
}
AudioOutputSource represents where the audio is played.
func (AudioOutputSource) String ¶
func (a AudioOutputSource) String() string
type ChannelInfo ¶ added in v0.1.0
type ChannelInfo struct {
ChannelID string `json:"channelId"`
ChannelName string `json:"channelName"`
ChannelNumber string `json:"channelNumber"`
ChannelModeName string `json:"channelModeName"`
SignalChannelID string `json:"signalChannelId"`
MajorNumber int `json:"majorNumber"`
MinorNumber int `json:"minorNumber"`
PhysicalNumber int `json:"physicalNumber"`
SourceIndex int `json:"sourceIndex"`
ChannelTypeId int `json:"channelTypeId"`
ChannelTypeName string `json:"channelTypeName"`
BinaryID int `json:"binaryId"`
ProgramID string `json:"programId"`
ChannelType string `json:"channelType"`
SatelliteName string `json:"satelliteName"`
FavoriteGroup string `json:"favoriteGroup"`
Skipped bool `json:"skipped"`
Locked bool `json:"locked"`
Scrambled bool `json:"scrambled"`
ServiceID int `json:"serviceId"`
TransportID int `json:"transportId"`
NetworkID int `json:"networkId"`
ChannelMode string `json:"channelMode"`
DualChannel bool `json:"dualChannel"`
TunerID int `json:"tunerId"`
ProgramName string `json:"programName"`
}
ChannelInfo contains information about a TV channel.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a WebOS TV client.
func Discover ¶
func Discover(ctx context.Context, opts ...DiscoverOption) ([]*Client, error)
Discover searches for WebOS TVs on the network.
func (*Client) Register ¶
func (c *Client) Register(ctx context.Context, store map[string]string) (<-chan RegistrationStatus, <-chan error)
Register performs the registration with the TV.
func (*Client) SendMessage ¶
func (c *Client) SendMessage( ctx context.Context, id string, requestType string, uri string, payload interface{}, ) (<-chan *Message, string, error)
SendMessage sends a message to the TV. If id is empty, a new UUID is generated. Its protocol fields remain separate to preserve the public API.
func (*Client) Unsubscribe ¶
Unsubscribe removes a subscription.
type DiscoverOption ¶ added in v0.1.0
type DiscoverOption func(*DiscoverOptions)
DiscoverOption is a functional option for Discover.
func WithDiscoverySecure ¶ added in v0.1.0
func WithDiscoverySecure(secure bool) DiscoverOption
WithDiscoverySecure sets whether discovered clients should use a secure connection.
func WithSearchWait ¶ added in v0.1.0
func WithSearchWait(wait int) DiscoverOption
WithSearchWait sets how long to wait for SSDP responses in seconds.
type DiscoverOptions ¶ added in v0.1.0
DiscoverOptions contains options for TV discovery.
type InputControl ¶
type InputControl struct {
Control
// contains filtered or unexported fields
}
InputControl provides methods for mouse and keyboard input.
func (*InputControl) Back ¶
func (i *InputControl) Back() error
func (*InputControl) Blue ¶
func (i *InputControl) Blue() error
func (*InputControl) Button ¶
func (i *InputControl) Button(name string) error
func (*InputControl) ChannelDown ¶
func (i *InputControl) ChannelDown() error
func (*InputControl) ChannelUp ¶
func (i *InputControl) ChannelUp() error
func (*InputControl) Click ¶
func (i *InputControl) Click() error
func (*InputControl) ConnectInput ¶
func (i *InputControl) ConnectInput(ctx context.Context) error
func (*InputControl) Dash ¶
func (i *InputControl) Dash() error
func (*InputControl) DisconnectInput ¶
func (i *InputControl) DisconnectInput() error
func (*InputControl) Down ¶
func (i *InputControl) Down() error
func (*InputControl) Exit ¶
func (i *InputControl) Exit() error
func (*InputControl) FastForward ¶
func (i *InputControl) FastForward() error
func (*InputControl) Green ¶
func (i *InputControl) Green() error
func (*InputControl) Home ¶
func (i *InputControl) Home() error
func (*InputControl) Info ¶
func (i *InputControl) Info() error
func (*InputControl) Left ¶
func (i *InputControl) Left() error
func (*InputControl) Menu ¶
func (i *InputControl) Menu() error
func (*InputControl) Mute ¶
func (i *InputControl) Mute() error
func (*InputControl) OK ¶
func (i *InputControl) OK() error
func (*InputControl) Pause ¶
func (i *InputControl) Pause() error
func (*InputControl) Play ¶
func (i *InputControl) Play() error
func (*InputControl) Red ¶
func (i *InputControl) Red() error
func (*InputControl) Rewind ¶
func (i *InputControl) Rewind() error
func (*InputControl) Right ¶
func (i *InputControl) Right() error
func (*InputControl) Scroll ¶
func (i *InputControl) Scroll(dx, dy int) error
func (*InputControl) Stop ¶
func (i *InputControl) Stop() error
func (*InputControl) Up ¶
func (i *InputControl) Up() error
func (*InputControl) VolumeDown ¶
func (i *InputControl) VolumeDown() error
func (*InputControl) VolumeUp ¶
func (i *InputControl) VolumeUp() error
func (*InputControl) Yellow ¶
func (i *InputControl) Yellow() error
type InputSource ¶
type InputSource struct {
ID string `json:"id"`
Label string `json:"label"`
Data map[string]interface{} `json:"-"`
}
InputSource represents a TV input source (e.g., HDMI1).
func (InputSource) String ¶
func (i InputSource) String() string
type MediaControl ¶
type MediaControl struct {
Control
}
MediaControl provides methods to control media and volume.
func (*MediaControl) FastForward ¶
func (m *MediaControl) FastForward(ctx context.Context) error
func (*MediaControl) GetAudioOutput ¶
func (m *MediaControl) GetAudioOutput(ctx context.Context) (*AudioOutputSource, error)
func (*MediaControl) GetVolume ¶
func (m *MediaControl) GetVolume(ctx context.Context) (*VolumeInfo, error)
func (*MediaControl) SetAudioOutput ¶
func (m *MediaControl) SetAudioOutput(ctx context.Context, output string) error
func (*MediaControl) SetVolume ¶
func (m *MediaControl) SetVolume(ctx context.Context, volume int) error
func (*MediaControl) SubscribeVolume ¶
func (m *MediaControl) SubscribeVolume(callback func(*VolumeInfo)) (string, error)
func (*MediaControl) VolumeDown ¶
func (m *MediaControl) VolumeDown(ctx context.Context) error
type Message ¶
type Message struct {
Type string `json:"type"`
ID string `json:"id"`
URI string `json:"uri,omitempty"`
Payload json.RawMessage `json:"payload,omitempty"`
}
Message is the basic unit of communication with WebOS TV.
type Option ¶ added in v0.1.0
type Option func(*clientOptions)
Option is a functional option for Client.
func WithHandshakeTimeout ¶ added in v0.1.0
WithHandshakeTimeout sets the timeout for the websocket handshake.
func WithSecure ¶ added in v0.1.0
WithSecure sets whether to use a secure (WSS) connection.
type RegistrationStatus ¶
type RegistrationStatus int
RegistrationStatus represents the status during the registration process.
const ( Prompted RegistrationStatus = iota + 1 Registered )
type SWInformation ¶ added in v0.1.0
type SWInformation struct {
ProductBaseVersion string `json:"product_base_version"`
ModelName string `json:"model_name"`
SDKVersion string `json:"sdk_version"`
FirmwareVersion string `json:"firmware_version"`
BoardType string `json:"board_type"`
OTAID string `json:"ota_id"`
}
SWInformation contains software information.
type SourceControl ¶
type SourceControl struct {
Control
}
SourceControl provides methods to manage input sources.
func (*SourceControl) ListSources ¶
func (s *SourceControl) ListSources(ctx context.Context) ([]InputSource, error)
type SystemControl ¶
type SystemControl struct {
Control
}
SystemControl provides methods for system-level operations.
func (*SystemControl) Info ¶
func (s *SystemControl) Info(ctx context.Context) (*SWInformation, error)
type TvControl ¶
type TvControl struct {
Control
}
TvControl provides methods for TV channel management.
func (*TvControl) ChannelList ¶
func (t *TvControl) ChannelList(ctx context.Context) ([]ChannelInfo, error)
func (*TvControl) GetCurrentChannel ¶
func (t *TvControl) GetCurrentChannel(ctx context.Context) (*ChannelInfo, error)
type VolumeInfo ¶ added in v0.1.0
type VolumeInfo struct {
Volume int `json:"volume"`
Mute bool `json:"mute"`
Scenario string `json:"scenario"`
SubScenario string `json:"subScenario"`
SoundOutput string `json:"soundOutput"`
Action string `json:"action"` // used in subscriptions
ChangeReason string `json:"changeReason"`
}
VolumeInfo contains volume related information.
