cc

package module
v0.0.0-...-43aa5ed Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: MIT Imports: 20 Imported by: 0

README

go-cc is a simple golang package for controlling Chromecast devices

Finding Chromecast devices on the network

All Google Cast devices and groups are discoverable on the network in the "_googlecast._tcp" mdns domain. Cast devices publish a variety of information about their current state using mdns, including:

  • Name
  • IPv4 address
  • ID number
  • Port they are listening on
  • Type of device (Chromecast Ultra, Chromecast Audio, SHIELD Android TV, Google Cast Group, etc.)
  • Currently loaded app, if one is loaded

***Finding Devices You can use the Finder functions in the go-cc package to find cast devices on your network.

package main
import (
	"fmt"
	cc "github.com/jerblack/go-cc"
)
func main() {
	finder := cc.NewDefaultFinder()
	CCs, e := finder.FindAll()
	if e == nil {
		for name, cc := range CCs {
			fmt.Printf("name: %s | ip: %s | kind: %s\n", name, cc.IP, cc.Kind)
		}
	}
}
/*
output: 
name: CCAs | ip: 192.168.0.204 | kind: Google Cast Group
name: Living Room speaker | ip: 192.168.0.225 | kind: Chromecast Audio
name: Bedroom Shield | ip: 192.168.0.209 | kind: SHIELD Android TV
name: Bedroom speaker | ip: 192.168.0.204 | kind: Chromecast Audio
name: Living room mini | ip: 192.168.0.213 | kind: Google Nest Mini
name: Bedroom Home | ip: 192.168.0.170 | kind: Google Home
name: Office speaker | ip: 192.168.0.232 | kind: Chromecast Audio
name: Living Room Chromecast | ip: 192.168.0.223 | kind: Chromecast Ultra
*/

You can customize the time to wait for mDNS queries and the timeout period for device control commands using cc.NewFinder() instead of cc.NewDefaultFinder()

func NewDefaultFinder() *Finder
func NewFinder(queryTimeout, ccTimeout time.Duration) *Finder

Three functions are provided for finding Chromecast devices.

// FindAll returns a map of all discovered devices with their name as the key.
func (f *Finder) FindAll() (map[string]*CC, error)
func (f *Finder) FindByIp(ip string) (*CC, error)
func (f *Finder) FindByName(name string) (*CC, error)

After finding the device you want to control, call start() on the instance of CC for that device before any attempting any other commands.

func (cc *CC) Start() error 

***Loading Media Once you've found the device you want to control, you can can start media on the device by passing MediaFile objects to one of the following functions. Media loads for playback in the native Default Media Receiver application found on all cast devices.

type MediaFile struct {
// required
Url, Mime  string
// optional
Title, Description string
}
// Load will load a single url for playback in the Default Media Receiver.
// Load takes an instance of MediaFile as it's only parameter
func (cc *CC) Load(file MediaFile) error
// LoadQueue will load multiple urls for playback in the Default Media Receiver.
// LoadQueue takes an array of MediaFile as it's only parameter
func (cc *CC) LoadQueue(files []MediaFile) error
// AppendQueue will append multiple urls to the existing queue
// for playback in the Default Media Receiver.
// AppendQueue takes an array of MediaFile as it's only parameter
func (cc *CC) AppendQueue(files []MediaFile) error

Example with LoadQueue()

package main
import (
	. "github.com/jerblack/go-cc"
	"log"
)
func main() {
	finder := NewDefaultFinder()
	cc, e := finder.FindByName("Living Room Chromecast")
	if e != nil {log.Fatalf(e.Error())}
	media := []MediaFile{
		MediaFile{
			Url: "https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/ElephantsDream.mp4",
			Mime: "video/mp4",
			Title: "Elephant Dream",
			Description: "The first Blender Open Movie from 2006",
		},
		MediaFile{
			Url: "https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/BigBuckBunny.mp4",
			Mime: "video/mp4",
			Title: "Big Buck Bunny",
			Description: "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself.",
		},
	}
	e = cc.Start()
	if e != nil {log.Fatalf(e.Error())}
	e = cc.LoadQueue(media)
	if e != nil {log.Fatalf(e.Error())}

}

***Controlling Media Playback

// Play resumes playback of the currently loaded media
func (cc *CC) Play() error
// Pause playback of the currently loaded media
func (cc *CC) Pause() error
// Stop interrupts playback of the currently loaded media and closes the Default Media Receiver application
func (cc *CC) Stop() error
// Volume sets the device level volume to a float64 value between 0.0 and 1.0
func (cc *CC) Volume(level float64) error
// Mute either mutes or unmutes audio at the device level depending on the boolean parameter given
func (cc *CC) Mute(truefalse bool) error
// Seek sets the current position in the stream for the currently loaded media.
// The parameter specifies the number of seconds since the beginning of the content.
func (cc *CC) Seek(seconds float64) error

Documentation

Index

Constants

View Source
const (
	DefaultMediaReceiver = "CC1AD845"
	Backdrop             = "E8C28D3C"
)
View Source
const (
	ISO8601Layout = "2006-01-02T15:04:05-0700"
)

Variables

View Source
var (
	CastMessage_ProtocolVersion_name = map[int32]string{
		0: "CASTV2_1_0",
	}
	CastMessage_ProtocolVersion_value = map[string]int32{
		"CASTV2_1_0": 0,
	}
)

Enum value maps for CastMessage_ProtocolVersion.

View Source
var (
	CastMessage_PayloadType_name = map[int32]string{
		0: "STRING",
		1: "BINARY",
	}
	CastMessage_PayloadType_value = map[string]int32{
		"STRING": 0,
		"BINARY": 1,
	}
)

Enum value maps for CastMessage_PayloadType.

View Source
var File_cast_clean_proto protoreflect.FileDescriptor
View Source
var Repeat = RepeatModes{
	Off:           pStr("REPEAT_OFF"),
	All:           pStr("REPEAT_ALL"),
	Single:        pStr("REPEAT_SINGLE"),
	AllAndShuffle: pStr("REPEAT_ALL_AND_SHUFFLE"),
}

Functions

func Query

func Query(params *QueryParam) error

Query looks up a given service, in a domain, waiting at most for a timeout before finishing the query. The results are streamed to a channel. Sends will not block, so clients should make sure to either read or buffer.

Types

type ApplicationSession

type ApplicationSession struct {
	AppID        *string      `json:"appId,omitempty"`
	DisplayName  *string      `json:"displayName,omitempty"`
	Namespaces   []*Namespace `json:"namespaces,omitempty"`
	IsIdleScreen bool         `json:"isIdleScreen,omitempty"`
	SessionID    *string      `json:"sessionId,omitempty"`
	StatusText   *string      `json:"statusText,omitempty"`
	TransportId  *string      `json:"transportId,omitempty"`
}

type Bus

type Bus struct {
	// contains filtered or unexported fields
}

type CC

type CC struct {
	IP   string `json:"ip"`
	Port int    `json:"port"`
	Kind string `json:"kind"`
	Name string `json:"name"`
	ID   string `json:"id"`
	// contains filtered or unexported fields
}

func NewCC

func NewCC(ip string, port int, timeout time.Duration) *CC

func (*CC) ClearQueue

func (cc *CC) ClearQueue() (*ReceiverStatus, error)

func (*CC) Close

func (cc *CC) Close() error

Close connection to cast device, stop playback, and invalidate queue

func (*CC) Disconnect

func (cc *CC) Disconnect()

Disconnect from cast device with stopping playback or disrupting queue

func (*CC) EnsureDmrRunning

func (cc *CC) EnsureDmrRunning() error

func (*CC) FetchItems

func (cc *CC) FetchItems(itemId int, nextCount, prevCount *int) (*MediaStatus, error)

FetchItems ...

func (*CC) GetCachedQueue

func (cc *CC) GetCachedQueue() *CachedQueue

func (*CC) GetCachedQueueIds

func (cc *CC) GetCachedQueueIds() *[]int

func (*CC) GetCurrentState

func (cc *CC) GetCurrentState() *State

GetCurrentState returns the State object as it currently exists without polling the device.

func (*CC) GetItemsInfo

func (cc *CC) GetItemsInfo(itemIds []int) (*[]QueueItem, error)

GetItemsInfo returns an array of QueueItems for currently loaded items in the queue. QueueItems directly match the format returned from the cast device

func (*CC) GetMediaFiles

func (cc *CC) GetMediaFiles(itemIds []int) (*[]MediaFile, error)

GetMediaFiles returns an array of MediaFiles for currently loaded items in the queue, which is parsed from the QueueItems returned from the cast device. This format matches the format used to load the queue.

func (*CC) GetMediaStatus

func (cc *CC) GetMediaStatus() (*MediaStatus, error)

GetMediaStatus polls the device for its current media state and returns the full response

func (*CC) GetReceiverStatus

func (cc *CC) GetReceiverStatus() (*ReceiverStatus, error)

GetReceiverStatus polls the device for its current receiver state and returns the full response

func (*CC) GetState

func (cc *CC) GetState() (*State, error)

GetState polls the device for its current receiver and media states and parses those into a combined State object with the most relevant fields, which is returned here.

func (*CC) InsertQueue

func (cc *CC) InsertQueue(files *[]*MediaFile, options *InsertQueueOptions) (*MediaStatus, error)

InsertQueue will append multiple urls to the existing queue for playback in the Default Media Receiver.

func (*CC) IsDmrRunning

func (cc *CC) IsDmrRunning() bool

func (*CC) Load

func (cc *CC) Load(file *MediaFile) (*MediaStatus, error)

Load will load a single url for playback in the Default Media Receiver. Load takes an instance of MediaFile as it's only parameter

func (*CC) LoadQueue

func (cc *CC) LoadQueue(files *[]*MediaFile, options *LoadQueueOptions) (*MediaStatus, error)

LoadQueue will load multiple urls for playback in the Default Media Receiver. options can be nil to use defaults

func (*CC) Mute

func (cc *CC) Mute(truefalse bool) (*ReceiverStatus, error)

Mute either mutes or unmutes audio at the device level depending on the boolean parameter given

func (*CC) Next

func (cc *CC) Next() (*MediaStatus, error)

Next skips to the next item in the current queue

func (*CC) Pause

func (cc *CC) Pause() (*MediaStatus, error)

Pause playback of the currently loaded media

func (*CC) Play

func (cc *CC) Play() (*MediaStatus, error)

Play resumes playback of the currently loaded media

func (*CC) PollState

func (cc *CC) PollState(interval time.Duration) (chan *State, func())

PollState periodically polls the device on the given interval for the current receiver and media states and parses those in a combined State object with the most relevant fields, which is then passed through the channel given in the first return value. The second return value is a function that should be called to stop the polling and close the channel

func (*CC) Previous

func (cc *CC) Previous() (*MediaStatus, error)

Previous skips to the previous item in the current queue

func (*CC) QueueGetItemIds

func (cc *CC) QueueGetItemIds() (*[]int, error)

GetQueueIds returns the item ids of the items in the currently loaded queue in the order those items occur in the queue.

func (*CC) RefreshQueue

func (cc *CC) RefreshQueue() (*CachedQueue, error)

func (*CC) RemoveQueue

func (cc *CC) RemoveQueue(itemIds []int, options *RemoveQueueOptions) (*MediaStatus, error)

RemoveQueue ...

func (*CC) ReorderQueue

func (cc *CC) ReorderQueue(itemIds []int, options *ReorderQueueOptions) (*MediaStatus, error)

ReorderQueue changes the order of the currently loaded queue. Specify one or more itemIds with no ReorderQueueOptions to move those items to the end of the queue. Specify one or more itemIds with ReorderQueueOptions.InsertBefore to move those items within the queue.

func (*CC) Seek

func (cc *CC) Seek(seconds float64) (*MediaStatus, error)

Seek sets the current position in the stream for the currently loaded media. The parameter specifies the number of seconds since the beginning of the content.

func (*CC) SetDeviceDebug

func (cc *CC) SetDeviceDebug(tf bool)

func (*CC) SetRepeatMode

func (cc *CC) SetRepeatMode(repeatMode *string) (*MediaStatus, error)

SetRepeatMode - set repeat mode in queue

func (*CC) ShuffleQueue

func (cc *CC) ShuffleQueue() (*[]int, error)

ShuffleQueue ...

func (*CC) Start

func (cc *CC) Start() error

Start should be called before using an instance of CC

func (*CC) StateTicker

func (cc *CC) StateTicker(interval time.Duration) (chan *State, func())

StateTicker watches for changes using the same method as SubscribeStateChanges (as opposed to actively polling the device). Additionally, a ticker is maintained internally and on the given interval, the position field is advanced by "interval" seconds in the local maintained copy of State while the media is playing, which is passed through the channel on the same interval. This allows you to, for example, set up a ticker that updates your web page every second without having to poll the device for changes.

func (*CC) Stop

func (cc *CC) Stop() error

Stop interrupts playback of the currently loaded media and closes the Default Media Receiver application

func (*CC) SubscribeStateChanges

func (cc *CC) SubscribeStateChanges() (chan *State, func())

SubscribeStateChanges will watch the device for all receiver and media status updates that are automatically passed whenever the state of the device changes. Any change such as playback started, playback paused or stopped, or the track changing will be passed by the device at the time they occur. Those updates are parsed into the State object which is passed through the channel returned as the first return value. The second return value is a function that should be called to stop the updates and close the channel

func (*CC) UnshuffleQueue

func (cc *CC) UnshuffleQueue() (*[]int, error)

UnshuffleQueue ...

func (*CC) UpdateQueue

func (cc *CC) UpdateQueue(options *UpdateQueueOptions) (*MediaStatus, error)

UpdateQueue ...

func (*CC) Volume

func (cc *CC) Volume(level float64) (*ReceiverStatus, error)

Volume sets the device level volume to a float64 value between 0.0 and 1.0

type CachedQueue

type CachedQueue struct {
	Order *[]int              `json:"order"`
	Items *map[int]*MediaFile `json:"items"`
}

type CastMessage

type CastMessage struct {
	ProtocolVersion *CastMessage_ProtocolVersion `` /* 146-byte string literal not displayed */
	SourceId        *string                      `protobuf:"bytes,2,req,name=source_id,json=sourceId" json:"source_id,omitempty"`
	DestinationId   *string                      `protobuf:"bytes,3,req,name=destination_id,json=destinationId" json:"destination_id,omitempty"`
	Namespace       *string                      `protobuf:"bytes,4,req,name=namespace" json:"namespace,omitempty"`
	PayloadType     *CastMessage_PayloadType     `` /* 130-byte string literal not displayed */
	PayloadUtf8     *string                      `protobuf:"bytes,6,opt,name=payload_utf8,json=payloadUtf8" json:"payload_utf8,omitempty"`
	PayloadBinary   []byte                       `protobuf:"bytes,7,opt,name=payload_binary,json=payloadBinary" json:"payload_binary,omitempty"`
	// contains filtered or unexported fields
}

func (*CastMessage) Descriptor deprecated

func (*CastMessage) Descriptor() ([]byte, []int)

Deprecated: Use CastMessage.ProtoReflect.Descriptor instead.

func (*CastMessage) GetDestinationId

func (x *CastMessage) GetDestinationId() string

func (*CastMessage) GetNamespace

func (x *CastMessage) GetNamespace() string

func (*CastMessage) GetPayloadBinary

func (x *CastMessage) GetPayloadBinary() []byte

func (*CastMessage) GetPayloadType

func (x *CastMessage) GetPayloadType() CastMessage_PayloadType

func (*CastMessage) GetPayloadUtf8

func (x *CastMessage) GetPayloadUtf8() string

func (*CastMessage) GetProtocolVersion

func (x *CastMessage) GetProtocolVersion() CastMessage_ProtocolVersion

func (*CastMessage) GetSourceId

func (x *CastMessage) GetSourceId() string

func (*CastMessage) ProtoMessage

func (*CastMessage) ProtoMessage()

func (*CastMessage) ProtoReflect

func (x *CastMessage) ProtoReflect() protoreflect.Message

func (*CastMessage) Reset

func (x *CastMessage) Reset()

func (*CastMessage) String

func (x *CastMessage) String() string

type CastMessage_PayloadType

type CastMessage_PayloadType int32
const (
	CastMessage_STRING CastMessage_PayloadType = 0
	CastMessage_BINARY CastMessage_PayloadType = 1
)

func (CastMessage_PayloadType) Descriptor

func (CastMessage_PayloadType) Enum

func (CastMessage_PayloadType) EnumDescriptor deprecated

func (CastMessage_PayloadType) EnumDescriptor() ([]byte, []int)

Deprecated: Use CastMessage_PayloadType.Descriptor instead.

func (CastMessage_PayloadType) Number

func (CastMessage_PayloadType) String

func (x CastMessage_PayloadType) String() string

func (CastMessage_PayloadType) Type

func (*CastMessage_PayloadType) UnmarshalJSON deprecated

func (x *CastMessage_PayloadType) UnmarshalJSON(b []byte) error

Deprecated: Do not use.

type CastMessage_ProtocolVersion

type CastMessage_ProtocolVersion int32
const (
	CastMessage_CASTV2_1_0 CastMessage_ProtocolVersion = 0
)

func (CastMessage_ProtocolVersion) Descriptor

func (CastMessage_ProtocolVersion) Enum

func (CastMessage_ProtocolVersion) EnumDescriptor deprecated

func (CastMessage_ProtocolVersion) EnumDescriptor() ([]byte, []int)

Deprecated: Use CastMessage_ProtocolVersion.Descriptor instead.

func (CastMessage_ProtocolVersion) Number

func (CastMessage_ProtocolVersion) String

func (CastMessage_ProtocolVersion) Type

func (*CastMessage_ProtocolVersion) UnmarshalJSON deprecated

func (x *CastMessage_ProtocolVersion) UnmarshalJSON(b []byte) error

Deprecated: Do not use.

type FetchItemsCommand

type FetchItemsCommand struct {
	PayloadHeader
	MediaSessionId *int `json:"mediaSessionId,omitempty"`
	ItemId         int  `json:"itemId"`
	NextCount      *int `json:"nextCount,omitempty"`
	PrevCount      *int `json:"prevCount,omitempty"`
}

https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.messages.FetchItemsRequestData

type Finder

type Finder struct {
	// contains filtered or unexported fields
}

func NewDefaultFinder

func NewDefaultFinder() *Finder

func NewFinder

func NewFinder(mdnsTimeout, ccTimeout time.Duration) *Finder

func (*Finder) FindAll

func (f *Finder) FindAll() (map[string]*CC, error)

func (*Finder) FindByID

func (f *Finder) FindByID(id string) (*CC, error)

func (*Finder) FindByIp

func (f *Finder) FindByIp(ip string) (*CC, error)

func (*Finder) FindByName

func (f *Finder) FindByName(name string) (*CC, error)

type GenericMetadata

type GenericMetadata struct {
	MetadataType int      `json:"metadataType"`          // 0: generic, 1: movie, 2: tv, 3: music, 4: photo
	Title        *string  `json:"title,omitempty"`       // optional: descriptive title text
	Subtitle     *string  `json:"subtitle,omitempty"`    // optional: descriptive subtitle text (not caption)
	Images       *[]Image `json:"images,omitempty"`      // optional: array of image urls associated with content
	ReleaseDate  *string  `json:"releaseDate,omitempty"` // optional: ISO 8601 date and time of release
}

func (GenericMetadata) GetDescription

func (m GenericMetadata) GetDescription() *string

func (GenericMetadata) GetMetadataType

func (m GenericMetadata) GetMetadataType() int

func (GenericMetadata) GetTitle

func (m GenericMetadata) GetTitle() *string

type GetItemsInfoCommand

type GetItemsInfoCommand struct {
	PayloadHeader
	MediaSessionId *int  `json:"mediaSessionId,omitempty"`
	ItemIds        []int `json:"itemIds"`
}

https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.messages.GetItemsInfoRequestData

type Headers

type Headers struct {
	Connect           PayloadHeader
	Close             PayloadHeader
	GetStatus         PayloadHeader
	Ping              PayloadHeader
	Pong              PayloadHeader
	Launch            PayloadHeader
	Stop              PayloadHeader
	Play              PayloadHeader
	Pause             PayloadHeader
	Seek              PayloadHeader
	Next              PayloadHeader
	Previous          PayloadHeader
	SetVolume         PayloadHeader
	Load              PayloadHeader
	QueueLoad         PayloadHeader
	QueueInsert       PayloadHeader
	QueueUpdate       PayloadHeader
	QueueRemove       PayloadHeader
	QueueReorder      PayloadHeader
	QueueShuffle      PayloadHeader
	QueueGetItemRange PayloadHeader
	QueueGetItems     PayloadHeader
	FetchItems        PayloadHeader
	GetItemsInfo      PayloadHeader
	QueueGetItemIds   PayloadHeader
}

https://developers.google.com/cast/docs/reference/messages

type HeartbeatBus

type HeartbeatBus struct {
	Bus
}

type Image

type Image struct {
	URL    string `json:"url"`
	Height *int   `json:"height,omitempty"` //optional
	Width  *int   `json:"width,omitempty"`  //optional
}

type InsertQueueOptions

type InsertQueueOptions struct {
	CurrentItemId    *int
	CurrentItemIndex *int
	InsertBefore     *int
	CurrentTime      *float32
}

type LaunchCmd

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

type LoadCommand

type LoadCommand struct {
	PayloadHeader
	Media MediaInformation `json:"media"`
	// optional: default is true
	Autoplay *bool `json:"autoplay,omitempty"`
	// optional: seconds from start of content to begin playback
	CurrentTime  *int `json:"currentTime,omitempty"`
	PlaybackRate *int `json:"playbackRate,omitempty"`
}

https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.messages.LoadRequestData

type LoadQueueOptions

type LoadQueueOptions struct {
	// REPEAT_OFF, REPEAT_ALL, REPEAT_SINGLE, REPEAT_ALL_AND_SHUFFLE, undefined/nil
	RepeatMode  *string
	StartIndex  *int
	CurrentTime *float32
}

type Manager

type Manager struct {
	DeviceDebug bool

	Current  map[int]chan *CastMessage
	Handlers map[string]func(*CastMessage)
	Closers  map[string]func(*CastMessage)
	// contains filtered or unexported fields
}

func NewManager

func NewManager() *Manager

type MediaBus

type MediaBus struct {
	Bus
	MediaSessionID *int
	// contains filtered or unexported fields
}

type MediaCommand

type MediaCommand struct {
	PayloadHeader
	MediaSessionID *int `json:"mediaSessionId,omitempty"`
}

type MediaFile

type MediaFile struct {
	// required
	Url  string `json:"url"`
	Mime string `json:"mime"`
	// optional: option 1
	Title       *string `json:"title"`
	Description *string `json:"description"`
	// optional: option 2
	Metadata MetadataVariant
}

func (*MediaFile) String

func (mf *MediaFile) String() string

type MediaInformation

type MediaInformation struct {
	ContentId     string          `json:"contentId"`          // url to content
	StreamType    string          `json:"streamType"`         // NONE, BUFFERED, or LIVE
	ContentType   string          `json:"contentType"`        // MIME type of content
	MediaCategory string          `json:"mediaCategory"`      // VIDEO, AUDIO, IMAGE
	Metadata      MetadataVariant `json:"metadata,omitempty"` // generic, movie, tv, music, or photo metadata struct
	Duration      *float64        `json:"duration,omitempty"` // optional
}

func (*MediaInformation) UnmarshalJSON

func (m *MediaInformation) UnmarshalJSON(b []byte) error

type MediaResponse

type MediaResponse struct {
	PayloadHeader
	Status []*MediaStatus `json:"status,omitempty"`
}

type MediaStatus

type MediaStatus struct {
	MediaSessionId         *int              `json:"mediaSessionId,omitempty"`
	PlaybackRate           *int              `json:"playbackRate,omitempty"`
	PlayerState            *string           `json:"playerState,omitempty"`
	IdleReason             *string           `json:"idleReason,omitempty"`
	CurrentTime            *float64          `json:"currentTime,omitempty"`
	SupportedMediaCommands *int              `json:"supportedMediaCommands,omitempty"`
	Volume                 *Volume           `json:"volume,omitempty"`
	ActiveTrackIds         []interface{}     `json:"activeTrackIds,omitempty"`
	Media                  *MediaInformation `json:"media,omitempty"`
	QueueData              *struct {
		RepeatMode string `json:"repeatMode,omitempty"`
		Shuffle    bool   `json:"shuffle,omitempty"`
		StartIndex int    `json:"startIndex,omitempty"`
	} `json:"queueData,omitempty"`
	CurrentItemId int `json:"currentItemId,omitempty"`
	Items         []struct {
		ItemId   int               `json:"itemId,omitempty"`
		Media    *MediaInformation `json:"media,omitempty"`
		Autoplay bool              `json:"autoplay,omitempty"`
		OrderId  int               `json:"orderId,omitempty"`
	} `json:"items,omitempty"`
	RepeatMode string `json:"repeatMode,omitempty"`
}

type MetadataVariant

type MetadataVariant interface {
	GetMetadataType() int
	GetTitle() *string
	GetDescription() *string
}

type MovieMetadata

type MovieMetadata struct {
	MetadataType int      `json:"metadataType"`          // 0: generic, 1: movie, 2: tv, 3: music, 4: photo
	Title        *string  `json:"title,omitempty"`       // optional: descriptive title text
	Subtitle     *string  `json:"subtitle,omitempty"`    // optional: descriptive subtitle text (not caption)
	Studio       *string  `json:"studio,omitempty"`      // optional
	Images       *[]Image `json:"images,omitempty"`      // optional: array of image urls associated with content
	ReleaseDate  *string  `json:"releaseDate,omitempty"` // optional: ISO 8601 date and time of release
}

func (MovieMetadata) GetDescription

func (m MovieMetadata) GetDescription() *string

func (MovieMetadata) GetMetadataType

func (m MovieMetadata) GetMetadataType() int

func (MovieMetadata) GetTitle

func (m MovieMetadata) GetTitle() *string

type MusicMetadata

type MusicMetadata struct {
	MetadataType int      `json:"metadataType"`          // 0: generic, 1: movie, 2: tv, 3: music, 4: photo
	AlbumName    *string  `json:"albumName,omitempty"`   // optional
	Title        *string  `json:"title,omitempty"`       // optional: song title
	AlbumArtist  *string  `json:"albumArtist,omitempty"` // optional
	Artist       *string  `json:"artist,omitempty"`      // optional
	Composer     *string  `json:"composer,omitempty"`    // optional
	TrackNumber  *int     `json:"trackNumber,omitempty"` // optional
	DiscNumber   *int     `json:"discNumber,omitempty"`  // optional
	Images       *[]Image `json:"images,omitempty"`      // optional: array of image urls associated with content
	ReleaseDate  *string  `json:"releaseDate,omitempty"` // optional: ISO 8601 date and time of release
}

func (MusicMetadata) GetDescription

func (m MusicMetadata) GetDescription() *string

func (MusicMetadata) GetMetadataType

func (m MusicMetadata) GetMetadataType() int

func (MusicMetadata) GetTitle

func (m MusicMetadata) GetTitle() *string

type Namespace

type Namespace struct {
	Name string `json:"name"`
}

type Namespaces

type Namespaces struct {
	// contains filtered or unexported fields
}

type PayloadHeader

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

type PayloadVariant

type PayloadVariant interface {
	// contains filtered or unexported methods
}

type PhotoMetadata

type PhotoMetadata struct {
	MetadataType     int      `json:"metadataType"`               // 0: generic, 1: movie, 2: tv, 3: music, 4: photo
	Title            *string  `json:"title,omitempty"`            // optional: descriptive title text
	Artist           *string  `json:"artist,omitempty"`           // optional
	Location         *string  `json:"location,omitempty"`         // optional: descriptive location -> "Madrid, Spain"
	Latitude         *float64 `json:"latitude,omitempty"`         // optional
	Longitude        *float64 `json:"longitude,omitempty"`        // optional
	Height           *int     `json:"height,omitempty"`           // optional
	Width            *int     `json:"width,omitempty"`            // optional
	CreationDateTime *string  `json:"creationDateTime,omitempty"` // optional: ISO 8601 date and time
}

func (PhotoMetadata) GetDescription

func (m PhotoMetadata) GetDescription() *string

func (PhotoMetadata) GetMetadataType

func (m PhotoMetadata) GetMetadataType() int

func (PhotoMetadata) GetTitle

func (m PhotoMetadata) GetTitle() *string

type QueryParam

type QueryParam struct {
	Service             string               // Service to lookup
	Domain              string               // Lookup domain, default "local"
	Timeout             time.Duration        // Lookup timeout, default 1 second
	Interface           *net.Interface       // Multicast interface to use
	Entries             chan<- *ServiceEntry // Entries Channel
	WantUnicastResponse bool                 // Unicast response desired, as per 5.4 in RFC
}

QueryParam is used to customize how a Lookup is performed

func DefaultParams

func DefaultParams(service string) *QueryParam

DefaultParams is used to return a default set of QueryParam's

type Queue

type Queue struct {
	ShuffleEnabled       bool   `json:"shuffleEnabled,omitempty"`
	ShuffleOriginalOrder *[]int `json:"shuffleOriginalOrder,omitempty"`
	Ids                  *[]int `json:"ids,omitempty"`
}

type QueueChangeResponse

type QueueChangeResponse struct {
	PayloadHeader
	// INSERT, REMOVE, ITEMS_CHANGE, UPDATE, NO_CHANGE, undefined/nil
	ChangeType     *string `json:"changeType,omitempty"`
	ItemIds        *[]int  `json:"itemIds,omitempty"`
	InsertBefore   *int    `json:"insertBefore,omitempty"`
	SequenceNumber *int    `json:"sequenceNumber,omitempty"`
}

https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.messages.QueueChange

type QueueCmd

type QueueCmd struct {
	PayloadHeader
	// number of seconds into content to begin playback after queue change
	CurrentTime    *float32 `json:"currentTime,omitempty"`
	MediaSessionId *int     `json:"mediaSessionId,omitempty"`
}

type QueueGetItemIdsCommand

type QueueGetItemIdsCommand struct {
	PayloadHeader
	MediaSessionId *int `json:"mediaSessionId,omitempty"`
}

type QueueInsertCommand

type QueueInsertCommand struct {
	QueueCmd
	Items            []QueueItem `json:"items"`
	CurrentItemId    *int        `json:"currentItemId,omitempty"`
	CurrentItemIndex *int        `json:"currentItemIndex,omitempty"`
	InsertBefore     *int        `json:"insertBefore,omitempty"`
}

https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.messages.QueueInsertRequestData

type QueueItem

type QueueItem struct {
	Media            MediaInformation `json:"media"`
	Autoplay         *bool            `json:"autoplay,omitempty"`
	PlaybackDuration *int             `json:"playbackDuration,omitempty"`
	// specify how long in seconds until the end of the previous item should preload of this item occur
	PreloadTime *int `json:"preloadTime,omitempty"`
	// specify how far in seconds into this item should playback begin
	StartTime *int `json:"startTime,omitempty"`
}

https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.messages.QueueItem

type QueueLoadCommand

type QueueLoadCommand struct {
	QueueCmd
	Items []QueueItem `json:"items"`
	// REPEAT_OFF, REPEAT_ALL, REPEAT_SINGLE, REPEAT_ALL_AND_SHUFFLE, undefined/nil
	RepeatMode *string `json:"repeatMode,omitempty"`
	StartIndex *int    `json:"startIndex,omitempty"`
}

https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.messages.QueueLoadRequestData

type QueueRemoveCommand

type QueueRemoveCommand struct {
	QueueCmd
	CurrentItemId *int  `json:"currentItemId,omitempty"`
	ItemIds       []int `json:"itemIds"`
}

https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.messages.QueueRemoveRequestData

type QueueReorderCommand

type QueueReorderCommand struct {
	QueueCmd
	CurrentItemId *int  `json:"currentItemId,omitempty"`
	ItemIds       []int `json:"itemIds"`
	InsertBefore  *int  `json:"insertBefore,omitempty"`
}

https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.messages.QueueReorderRequestData

type QueueUpdateCommand

type QueueUpdateCommand struct {
	QueueCmd
	Jump *int `json:"jump,omitempty"`
	// id of current media item after change
	CurrentItemId *int         `json:"currentItemId,omitempty"`
	Items         *[]QueueItem `json:"items,omitempty"`
	Shuffle       *bool        `json:"shuffle,omitempty"`
	// REPEAT_OFF, REPEAT_ALL, REPEAT_SINGLE, REPEAT_ALL_AND_SHUFFLE, undefined/nil
	RepeatMode *string `json:"repeatMode,omitempty"`
}

https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.messages.QueueUpdateRequestData

type ReceiverBus

type ReceiverBus struct {
	Bus
}

type ReceiverResponse

type ReceiverResponse struct {
	PayloadHeader
	Status *ReceiverStatus `json:"status,omitempty"`
}

type ReceiverStatus

type ReceiverStatus struct {
	PayloadHeader
	Applications []*ApplicationSession `json:"applications,omitempty"`
	Volume       *Volume               `json:"volume,omitempty"`
}

type RemoveQueueOptions

type RemoveQueueOptions struct {
	CurrentItemId *int
	CurrentTime   *float32
}

type ReorderQueueOptions

type ReorderQueueOptions struct {
	CurrentTime   *float32
	CurrentItemId *int `json:"currentItemId,omitempty"`
	InsertBefore  *int `json:"insertBefore"`
}

type RepeatModes

type RepeatModes struct {
	Off, All, Single, AllAndShuffle *string
}

type SeekCommand

type SeekCommand struct {
	PayloadHeader
	MediaSessionID *int `json:"mediaSessionId,omitempty"`
	// optional: PLAYBACK_START or PLAYBACK_PAUSE. if not set, current playing state is retained
	ResumeState *string `json:"resumeState,omitempty"`
	// seconds since beginning of content
	CurrentTime *float64 `json:"currentTime,omitempty"`
}

type ServiceEntry

type ServiceEntry struct {
	Name       string
	Host       string
	AddrV4     net.IP
	AddrV6     net.IP
	Port       int
	Info       string
	InfoFields []string
	// contains filtered or unexported fields
}

ServiceEntry is returned after we query for a service

type SetPlaybackRateCommand

type SetPlaybackRateCommand struct {
	PayloadHeader
	MediaSessionId *int `json:"mediaSessionId,omitempty"`
	// New playback rate (>0).
	PlaybackRate *float64 `json:"playbackRate"`
	// rate relative to current. 1.1 will increase rate by 10%
	RelativePlaybackRate *float64 `json:"relativePlaybackRate"`
}

https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.messages.SetPlaybackRateRequestData

type ShuffleQueueCommand

type ShuffleQueueCommand struct {
	PayloadHeader
	MediaSessionId *int     `json:"mediaSessionId,omitempty"`
	CurrentItemId  *int     `json:"currentItemId,omitempty"`
	CurrentTime    *float32 `json:"currentTime,omitempty"`
}

type State

type State struct {
	Media    *MediaStatus
	Receiver *ReceiverStatus
	Queue    *Queue
}

func (*State) AppId

func (s *State) AppId() *string

func (*State) CurrentItemId

func (s *State) CurrentItemId() *int

func (*State) IsFinished

func (s *State) IsFinished() bool

func (*State) IsIdleScreen

func (s *State) IsIdleScreen() bool

func (*State) MediaSessionId

func (s *State) MediaSessionId() *int

func (*State) RepeatMode

func (s *State) RepeatMode() *string

func (*State) SessionId

func (s *State) SessionId() *string

func (*State) Title

func (s *State) Title() *string

func (*State) Url

func (s *State) Url() *string

func (*State) Volume

func (s *State) Volume() *Volume

type Stream

type Stream struct {
	// contains filtered or unexported fields
}

func NewStream

func NewStream(ip string, port int, mgr *Manager) (*Stream, error)

func (*Stream) Close

func (s *Stream) Close() error

func (*Stream) Read

func (s *Stream) Read() *[]byte

func (*Stream) Write

func (s *Stream) Write(chunk *[]byte) (int, error)

type TvMetadata

type TvMetadata struct {
	MetadataType    int      `json:"metadataType"`              // 0: generic, 1: movie, 2: tv, 3: music, 4: photo
	SeriesTitle     *string  `json:"seriesTitle,omitempty"`     // optional
	Subtitle        *string  `json:"subtitle,omitempty"`        // optional: descriptive subtitle text (not caption)
	Season          *int     `json:"season,omitempty"`          // optional: season number
	Episode         *int     `json:"episode,omitempty"`         // optional: episode number
	Images          *[]Image `json:"images,omitempty"`          // optional: array of image urls associated with content
	OriginalAirDate *string  `json:"originalAirDate,omitempty"` // optional: ISO 8601 date and time of first airing
}

func (TvMetadata) GetDescription

func (m TvMetadata) GetDescription() *string

func (TvMetadata) GetMetadataType

func (m TvMetadata) GetMetadataType() int

func (TvMetadata) GetTitle

func (m TvMetadata) GetTitle() *string

type UpdateQueueOptions

type UpdateQueueOptions struct {
	Jump *int
	// id of current media item after change
	CurrentItemId *int
	Files         *[]*MediaFile
	Shuffle       *bool
	// REPEAT_OFF, REPEAT_ALL, REPEAT_SINGLE, REPEAT_ALL_AND_SHUFFLE, undefined/nil
	RepeatMode  *string
	CurrentTime *float32
}

type Volume

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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