googlecast

package
v3.0.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2020 License: BSD-2-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CAST_DEFAULT_SENDER   = "sender-0"
	CAST_DEFAULT_RECEIVER = "receiver-0"
	CAST_NS_CONN          = "urn:x-cast:com.google.cast.tp.connection"
	CAST_NS_HEARTBEAT     = "urn:x-cast:com.google.cast.tp.heartbeat"
	CAST_NS_RECV          = "urn:x-cast:com.google.cast.receiver"
	CAST_NS_MEDIA         = "urn:x-cast:com.google.cast.media"
	CAST_NS_MULTIZONE     = "urn:x-cast:com.google.cast.multizone"
)

Variables

This section is empty.

Functions

func NewEvent

func NewEvent(device *Cast, flags gopi.CastFlag, reqId int) gopi.CastEvent

func NewState

func NewState(key string, req int, values ...interface{}) state

Types

type App

type App struct {
	AppId        string `json:"appId"`
	DisplayName  string `json:"displayName"`
	IsIdleScreen bool   `json:"isIdleScreen"`
	SessionId    string `json:"sessionId"`
	StatusText   string `json:"statusText"`
	TransportId  string `json:"transportId"`
}

func (App) Equals

func (a App) Equals(other App) bool

func (App) String

func (a App) String() string

type Cast

type Cast struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewCastFromRecord

func NewCastFromRecord(r gopi.ServiceRecord) *Cast

func (*Cast) Addr

func (this *Cast) Addr() string

func (*Cast) Call

func (this *Cast) Call(id int) error

func (*Cast) Connect

func (this *Cast) Connect(key, addr string, timeout time.Duration, errs chan<- error, state chan<- state) error

func (*Cast) ConnectWithTimeout

func (this *Cast) ConnectWithTimeout(timeout time.Duration, errs chan<- error, state chan<- state) error

func (*Cast) Disconnect

func (this *Cast) Disconnect() error

func (*Cast) Dispose

func (this *Cast) Dispose()

func (*Cast) Id

func (this *Cast) Id() string

Id returns the identifier for a chromecast

func (*Cast) InitWithTimeout

func (this *Cast) InitWithTimeout(timeout time.Duration)

func (*Cast) Model

func (this *Cast) Model() string

Model returns the reported model information

func (*Cast) Name

func (this *Cast) Name() string

Name returns the readable name for a chromecast

func (*Cast) ReqAppConnect

func (this *Cast) ReqAppConnect(fn func() error) error

func (*Cast) ReqLaunchAppWithId

func (this *Cast) ReqLaunchAppWithId(appId string) error

func (*Cast) ReqLoadURL

func (this *Cast) ReqLoadURL(url *url.URL, mimetype string, autoplay bool) error

func (*Cast) ReqMediaConnect

func (this *Cast) ReqMediaConnect(fn func() error) error

func (*Cast) ReqMuted

func (this *Cast) ReqMuted(muted bool) error

func (*Cast) ReqPause

func (this *Cast) ReqPause(state bool) error

func (*Cast) ReqPlay

func (this *Cast) ReqPlay(state bool) error

func (*Cast) ReqSeek

func (this *Cast) ReqSeek(value int) error

func (*Cast) ReqStop

func (this *Cast) ReqStop() error

func (*Cast) ReqVolumeLevel

func (this *Cast) ReqVolumeLevel(level float32) error

func (*Cast) Service

func (this *Cast) Service() string

Service returns the currently running service

func (*Cast) Set

func (this *Cast) Set(id int, fn func() error)

func (*Cast) SetApp

func (this *Cast) SetApp(a App) (gopi.CastFlag, error)

func (*Cast) SetMedia

func (this *Cast) SetMedia(m Media) (gopi.CastFlag, error)

func (*Cast) SetState

func (this *Cast) SetState(s state) (gopi.CastFlag, error)

func (*Cast) SetVolume

func (this *Cast) SetVolume(v Volume) (gopi.CastFlag, error)

func (*Cast) State

func (this *Cast) State() uint

State returns 0 if backdrop, else returns 1

func (*Cast) String

func (this *Cast) String() string

func (*Cast) UpdateState

func (this *Cast) UpdateState() error

type LaunchAppRequest

type LaunchAppRequest struct {
	PayloadHeader
	AppId string `json:"appId"`
}

func (*LaunchAppRequest) WithId

func (this *LaunchAppRequest) WithId(id int) Payload

type LoadMediaRequest

type LoadMediaRequest struct {
	PayloadHeader
	Media       MediaItem `json:"media"`
	CurrentTime int       `json:"currentTime,omitempty"`
	Autoplay    bool      `json:"autoplay,omitempty"`
	ResumeState string    `json:"resumeState,omitempty"`
}

func (*LoadMediaRequest) WithId

func (this *LoadMediaRequest) WithId(id int) Payload

type LoadQueueItem

type LoadQueueItem struct {
	PayloadHeader
	Media            MediaItem `json:"media"`
	Autoplay         bool      `json:"autoplay"`
	PlaybackDuration uint      `json:"playbackDuration"`
}

type LoadQueueRequest

type LoadQueueRequest struct {
	PayloadHeader
	RepeatMode string          `json:"repeatMode"`
	Items      []LoadQueueItem `json:"items"`
}

type Manager

type Manager struct {
	sync.RWMutex
	gopi.Unit
	gopi.ServiceDiscovery
	gopi.Publisher
	gopi.Logger
	// contains filtered or unexported fields
}

func (*Manager) Connect

func (this *Manager) Connect(device gopi.Cast) error

func (*Manager) Devices

func (this *Manager) Devices(ctx context.Context) ([]gopi.Cast, error)

func (*Manager) Disconnect

func (this *Manager) Disconnect(device gopi.Cast) error

func (*Manager) Dispose

func (this *Manager) Dispose() error

func (*Manager) LaunchAppWithId

func (this *Manager) LaunchAppWithId(cast gopi.Cast, appId string) error

func (*Manager) LoadURL

func (this *Manager) LoadURL(cast gopi.Cast, url *url.URL, autoplay bool) error

func (*Manager) New

func (this *Manager) New(gopi.Config) error

func (*Manager) Run

func (this *Manager) Run(ctx context.Context) error

func (*Manager) Seek

func (this *Manager) Seek(cast gopi.Cast, value time.Duration) error

func (*Manager) SetMuted

func (this *Manager) SetMuted(cast gopi.Cast, value bool) error

func (*Manager) SetPause

func (this *Manager) SetPause(cast gopi.Cast, value bool) error

func (*Manager) SetPlay

func (this *Manager) SetPlay(cast gopi.Cast, value bool) error

func (*Manager) SetVolume

func (this *Manager) SetVolume(cast gopi.Cast, value float32) error

func (*Manager) Stop

func (this *Manager) Stop(cast gopi.Cast) error

func (*Manager) String

func (this *Manager) String() string

type Media

type Media struct {
	MediaSessionId int `json:"mediaSessionId"`

	// PLAYING, BUFFERING, PAUSED, IDLE or UNKNOWN
	PlayerState string `json:"playerState"`

	// CurrentTime in seconds
	CurrentTime float32 `json:"currentTime"`

	IdleReason    string    `json:"idleReason"`
	Volume        Volume    `json:"volume"`
	CurrentItemId int       `json:"currentItemId"`
	LoadingItemId int       `json:"loadingItemId"`
	Media         MediaItem `json:"media"`
}

func (Media) Equals

func (m Media) Equals(other Media) bool

func (Media) String

func (m Media) String() string

type MediaImage

type MediaImage struct {
	URL    string `json:"url"`
	Height int    `json:"height"`
	Width  int    `json:"width"`
}

func (MediaImage) String

func (m MediaImage) String() string

type MediaItem

type MediaItem struct {
	ContentId string `json:"contentId"`

	// Mimetype
	ContentType string `json:"contentType,omitempty"`

	// BUFFERED, LIVE or UNKNOWN
	StreamType string `json:"streamType,omitempty"`

	// Duration in seconds
	Duration float32        `json:"duration,omitempty"`
	Metadata *MediaMetadata `json:"metadata,omitempty"`
}

func (MediaItem) Equals

func (m MediaItem) Equals(other MediaItem) bool

func (MediaItem) String

func (m MediaItem) String() string

type MediaMetadata

type MediaMetadata struct {
	MetadataType int          `json:"metadataType,omitempty"`
	Artist       string       `json:"artist,omitempty"`
	Title        string       `json:"title,omitempty"`
	Subtitle     string       `json:"subtitle,omitempty"`
	Images       []MediaImage `json:"images,omitempty"`
	ReleaseDate  string       `json:"releaseDate,omitempty"`
}

func (*MediaMetadata) Equals

func (m *MediaMetadata) Equals(other *MediaMetadata) bool

func (MediaMetadata) String

func (m MediaMetadata) String() string

type MediaRequest

type MediaRequest struct {
	PayloadHeader
	MediaSessionId int    `json:"mediaSessionId"`
	CurrentTime    int    `json:"currentTime,omitempty"`
	ResumeState    string `json:"resumeState,omitempty"`
}

type MediaStatusResponse

type MediaStatusResponse struct {
	PayloadHeader
	Status []Media `json:"status"`
}

type Payload

type Payload interface {
	WithId(id int) Payload
}

type PayloadHeader

type PayloadHeader struct {
	Type      string `json:"type"`
	RequestId int    `json:"requestId,omitempty"`
}

func (*PayloadHeader) WithId

func (this *PayloadHeader) WithId(id int) Payload

type QueueUpdate

type QueueUpdate struct {
	PayloadHeader
	Media            MediaItem `json:"media"`
	Autoplay         bool      `json:"autoplay"`
	PlaybackDuration uint      `json:"playbackDuration"`
}

type ReceiverStatusResponse

type ReceiverStatusResponse struct {
	PayloadHeader
	Status struct {
		Apps   []App `json:"applications"`
		Volume `json:"volume"`
	} `json:"status"`
}

type SetVolumeRequest

type SetVolumeRequest struct {
	PayloadHeader
	Volume `json:"volume"`
}

func (*SetVolumeRequest) WithId

func (this *SetVolumeRequest) WithId(id int) Payload

type Volume

type Volume struct {
	Level float32 `json:"level,omitempty"`
	Muted bool    `json:"muted"`
}

func (Volume) Equals

func (v Volume) Equals(other Volume) bool

func (Volume) String

func (v Volume) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL