Documentation ¶
Index ¶
- Constants
- Variables
- func Discover(ctx context.Context) (<-chan *DeviceInfo, error)
- type DeviceCapability
- type DeviceInfo
- type MediaInformation
- type MediaMetadata
- type MediaSession
- type MediaStatus
- type Receiver
- func (r *Receiver) Application() *ReceiverApplication
- func (r *Receiver) Close() error
- func (r *Receiver) Connect() error
- func (r *Receiver) IsConnected() bool
- func (r *Receiver) Launch(appID string) error
- func (r *Receiver) Load(senderID string, media *MediaInformation) error
- func (r *Receiver) Pause(senderID string, mediaSessionID int) error
- func (r *Receiver) Play(senderID string, mediaSessionID int) error
- func (r *Receiver) Seek(senderID string, mediaSessionID int, pos float64) error
- func (r *Receiver) Session(senderID string) (*MediaSession, time.Time)
- func (r *Receiver) SetVolume(vol *ReceiverVolume) error
- func (r *Receiver) Stop(senderID string, mediaSessionID int) error
- func (r *Receiver) Volume() *ReceiverVolume
- type ReceiverApplication
- type ReceiverStatus
- type ReceiverVolume
- type Sender
- func (s *Sender) Close() error
- func (s *Sender) IsBuffering() bool
- func (s *Sender) IsIdle() bool
- func (s *Sender) IsMuted() bool
- func (s *Sender) IsPaused() bool
- func (s *Sender) IsPlaying() bool
- func (s *Sender) Load(mediaURL *url.URL, mediaMetadata omnicast.MediaMetadata) error
- func (s *Sender) MediaDuration() time.Duration
- func (s *Sender) MediaMetadata() omnicast.MediaMetadata
- func (s *Sender) MediaURL() *url.URL
- func (s *Sender) Mute()
- func (s *Sender) Name() string
- func (s *Sender) Pause()
- func (s *Sender) Play()
- func (s *Sender) PlaybackPosition() time.Duration
- func (s *Sender) PlaybackRate() float32
- func (s *Sender) PlayerState() string
- func (s *Sender) SeekTo(pos time.Duration)
- func (s *Sender) SetVolumeLevel(level float64)
- func (s *Sender) Stop()
- func (s *Sender) Unmute()
- func (s *Sender) VolumeLevel() float64
Constants ¶
const ( DefaultReceiverAppID = "CC1AD845" YouTubeReceiverAppID = "233637DE" )
Common receiver app IDs.
Variables ¶
var ( ErrReceiverNotReady = errors.New("receiver not ready") ErrInvalidMedia = errors.New("invalid media") )
Errors used by the Sender.
Functions ¶
Types ¶
type DeviceCapability ¶
type DeviceCapability uint
DeviceCapability represents one of the defined device capabilities.
const ( None DeviceCapability = 0 VideoOut DeviceCapability = 1 << 0 VideoIn DeviceCapability = 1 << 1 AudioOut DeviceCapability = 1 << 2 AudioIn DeviceCapability = 1 << 3 DevMode DeviceCapability = 1 << 4 MultizoneGroup DeviceCapability = 1 << 5 )
Defined Google Cast device capabilities.
Source: https://github.com/chromium/chromium/blob/master/components/cast_channel/cast_socket.h#L46
func (DeviceCapability) String ¶
func (c DeviceCapability) String() string
String returns the string representation of the device capability.
type DeviceInfo ¶
type DeviceInfo struct { UUID uuid.UUID Name string `json:"name"` Model string IPv4 net.IP IPv6 net.IP Port int // contains filtered or unexported fields }
func GetDeviceInfo ¶
func GetDeviceInfo(ip net.IP) (*DeviceInfo, error)
func (*DeviceInfo) Capabilities ¶
func (d *DeviceInfo) Capabilities() []DeviceCapability
Capabilities returns a list of device capabilities.
func (*DeviceInfo) CapableOf ¶
func (d *DeviceInfo) CapableOf(capabilities ...DeviceCapability) bool
CapableOf returns true if the device has all given capabilities.
func (*DeviceInfo) TCPAddr ¶
func (d *DeviceInfo) TCPAddr() *net.TCPAddr
TCPAddr returns IPv4 and Port as net.TCPAddr.
type MediaInformation ¶
type MediaInformation struct { ContentID string `json:"contentId"` ContentType string `json:"contentType"` StreamType string `json:"streamType"` Metadata MediaMetadata `json:"metadata,omitempty"` Duration float64 `json:"duration,omitempty"` }
MediaInformation represents a media stream.
Ref: https://developers.google.com/cast/docs/reference/messages#MediaInformation
type MediaMetadata ¶
type MediaMetadata map[string]interface{}
MediaMetadata represents a generic media artifact.
Ref: https://developers.google.com/cast/docs/reference/messages#GenericMediaMetadata
https://developers.google.com/cast/docs/reference/messages#Image
func (MediaMetadata) ImageURL ¶
func (m MediaMetadata) ImageURL() *url.URL
ImageURL returns the URL of the image.
func (MediaMetadata) Subtitle ¶
func (m MediaMetadata) Subtitle() string
Subtitle returns the descriptive subtitle of the content.
func (MediaMetadata) Title ¶
func (m MediaMetadata) Title() string
Title returns the descriptive title of the content.
type MediaSession ¶
type MediaSession struct { MediaSessionID int `json:"mediaSessionId"` Media *MediaInformation `json:"media,omitempty"` PlaybackRate float32 `json:"playbackRate"` PlayerState string `json:"playerState"` IdleReason string `json:"idleReason,omitempty"` CurrentTime float64 `json:"currentTime"` SupportedMediaCommands int `json:"supportedMediaCommands"` }
MediaSession represents the current status of a single session.
type MediaStatus ¶
type MediaStatus struct {
Status []*MediaSession `json:"status"`
}
MediaStatus represents the current status of the media artifact with respect to the session.
https://developers.google.com/cast/docs/reference/messages#MediaStatus
type Receiver ¶
type Receiver struct { *DeviceInfo // contains filtered or unexported fields }
Receiver represents a Google Cast device.
func (*Receiver) Application ¶
func (r *Receiver) Application() *ReceiverApplication
Application returns the current running receiver application, if any.
func (*Receiver) IsConnected ¶
IsConnected returns true if there is an active connection to the receiver device.
func (*Receiver) Load ¶
func (r *Receiver) Load(senderID string, media *MediaInformation) error
Load loads new content into the media player.
Ref: https://developers.google.com/cast/docs/reference/messages#Load
func (*Receiver) Pause ¶
Pause pauses playback of the current content.
https://developers.google.com/cast/docs/reference/messages#Pause
func (*Receiver) Play ¶
Play begins playback of the loaded media content from the current playback position.
https://developers.google.com/cast/docs/reference/messages#Play
func (*Receiver) Seek ¶
Seek sets the current playback position to pos, which is the number of seconds since beginning of content
func (*Receiver) Session ¶
func (r *Receiver) Session(senderID string) (*MediaSession, time.Time)
GetSession returns the last known status of the media session.
func (*Receiver) SetVolume ¶
func (r *Receiver) SetVolume(vol *ReceiverVolume) error
SetVolume sets the receiver volume.
func (*Receiver) Stop ¶
Stop stops the playback and unload the current content
https://developers.google.com/cast/docs/reference/messages#Stop
func (*Receiver) Volume ¶
func (r *Receiver) Volume() *ReceiverVolume
Volume returns the receiver volume, if known.
type ReceiverApplication ¶
type ReceiverApplication struct { AppID string `json:"appId"` Name string `json:"displayName"` IconURL string `json:"iconUrl"` StatusText string `json:"statusText"` IsIdleScreen bool `json:"isIdleScreen"` SupportedNamespaces []map[string]string `json:"namespaces"` SessionID string `json:"sessionId"` TransportID string `json:"transportId"` }
ReceiverApplication represents an instance of receiver application.
type ReceiverStatus ¶
type ReceiverStatus struct { castv2.Header Status struct { Applications []*ReceiverApplication `json:"applications,omitempty"` Volume *ReceiverVolume `json:"volume"` } `json:"status"` }
ReceiverStatus represents the devices status of the receiver.
type ReceiverVolume ¶
type ReceiverVolume struct { ControlType string `json:"controlType,omitempty"` Level float64 `json:"level,omitempty"` Muted bool `json:"muted,omitempty"` StepInterval float64 `json:"stepInterval,omitempty"` }
ReceiverVolume represents the volume of the receiver device.
type Sender ¶
type Sender struct { ID string // contains filtered or unexported fields }
A Sender is a sender app instance that controls media playback on the receiver. Its ID, which should be unique, is used to identify itself when communicating with the receiver.
func NewSender ¶
func NewSender(id string, dev *DeviceInfo) (*Sender, error)
NewSender returns a new Sender and connects to the device.
func (*Sender) IsBuffering ¶
IsBuffering returns true if playback is effectively paused due to buffer underflow.
func (*Sender) IsIdle ¶
IsIdle returns true if the recevier device does not have an receiver app running or have media playback stopped.
func (*Sender) MediaDuration ¶
MediaDuration returns the duration of current loaded media.
func (*Sender) MediaMetadata ¶
func (s *Sender) MediaMetadata() omnicast.MediaMetadata
MediaMetadata returns the metadata of current loaded media.
func (*Sender) Play ¶
func (s *Sender) Play()
Play begins playback of the loaded media content from the current playback position.
func (*Sender) PlaybackPosition ¶
PlaybackPosition returns the current position of media playback from the beginning of media content. For live streams, it returns the time since playback started.
func (*Sender) PlaybackRate ¶
PlaybackRate returns the ratio of speed that media is played at.
func (*Sender) PlayerState ¶
PlayerState return the current playback state.
func (*Sender) SetVolumeLevel ¶
SetVolumeLevel sets receiver volume level.
func (*Sender) Stop ¶
func (s *Sender) Stop()
Stop stops the playback and unload the current content
func (*Sender) VolumeLevel ¶
VolumeLevel returns receiver volume as a number between 0.0 and 1.0.