airplay

package module
v0.0.0-...-a7a18a4 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2016 License: MIT Imports: 16 Imported by: 22

README

go-airplay

GoDoc Build Status Coverage Status

Go bindings for AirPlay client

Usage

Videos
import "github.com/gongo/go-airplay"

client, err := airplay.FirstClient()
if err != nil {
	log.Fatal(err)
}

ch := client.Play("http://movie.example.com/go.mp4")

// Block until have played content to the end
<-ch

If device is required password:

client.SetPassword("password")

Specifying the start position:

// Start from 42% of length of content.
client.PlayAt("http://movie.example.com/go.mp4", 0.42)

Other API:

// Seek to 120 seconds from start position.
client.Scrub(120.0)

// Change playback rate
client.Rate(0.0) // pause
client.Rate(1.0) // resume

See:

Images
// local file
client.Photo("/path/to/gopher.jpg")

// remote file
client.Photo("http://blog.golang.org/gopher/plush.jpg")

You can specify the transition want to slide:

client.Photo("/path/to/gopher.jpg", airplay.SlideNone) // eq client.Photo("..")
client.Photo("/path/to/gopher.jpg", airplay.SlideDissolve)
client.Photo("/path/to/gopher.jpg", airplay.SlideRight)
client.Photo("/path/to/gopher.jpg", airplay.SlideLeft)

See example/slideshow :

Devices
// Get all AirPlay devices in LAN.
devices := airplay.Devices()

// Get the first found AirPlay device in LAN.
device := airplay.FirstDevice()

See example/devices :

LICENSE

MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func FirstClient

func FirstClient() (*Client, error)

FirstClient return the AirPlay Client that has the first found AirPlay device in LAN

func NewClient

func NewClient(params *ClientParam) (*Client, error)

func (*Client) GetPlaybackInfo

func (c *Client) GetPlaybackInfo() (*PlaybackInfo, error)

GetPlaybackInfo retrieves playback informations.

func (*Client) Photo

func (c *Client) Photo(path string)

Photo show a JPEG picture. It can specify both remote or local file.

A trivial example:

// local file
client.Photo("/path/to/gopher.jpg")

// remote file
client.Photo("http://blog.golang.org/gopher/plush.jpg")

func (*Client) PhotoWithSlide

func (c *Client) PhotoWithSlide(path string, transition SlideTransition)

PhotoWithSlide show a JPEG picture in the transition specified.

func (*Client) Play

func (c *Client) Play(url string) <-chan error

Play start content playback.

When playback is finished, sends termination status on the returned channel. If non-nil, not a successful termination.

func (*Client) PlayAt

func (c *Client) PlayAt(url string, position float64) <-chan error

PlayAt start content playback by specifying the start position.

Returned channel is the same as Play().

func (*Client) Rate

func (c *Client) Rate(rate float64)

Rate change the playback rate in playing content.

If rate is 0, content is paused. if rate is 1, content playing at the normal speed.

func (*Client) Scrub

func (c *Client) Scrub(position float64)

Scrub seeks at position seconds in playing content.

func (Client) SetPassword

func (c Client) SetPassword(password string)

func (*Client) Stop

func (c *Client) Stop()

Stop exits content playback.

type ClientParam

type ClientParam struct {
	Addr     string
	Port     int
	Password string
}

type DNSResponseParseError

type DNSResponseParseError struct {
	Type    string
	Records []dns.RR
}

func NewDNSResponseParseError

func NewDNSResponseParseError(t string, r []dns.RR) *DNSResponseParseError

func (*DNSResponseParseError) Error

func (e *DNSResponseParseError) Error() string

type Device

type Device struct {
	Name  string
	Addr  string
	Port  int
	Extra DeviceExtra
}

A Device is an AirPlay Device.

func Devices

func Devices() []Device

Devices returns all AirPlay devices in LAN.

func FirstDevice

func FirstDevice() Device

FirstDevice return the first found AirPlay device in LAN.

type DeviceExtra

type DeviceExtra struct {
	Model              string
	Features           string
	MacAddress         string
	ServerVersion      string
	IsPasswordRequired bool
}

A DeviceExtra is extra information of AirPlay device.

type PlaybackInfo

type PlaybackInfo struct {
	// IsReadyToPlay, if true, content is currently playing or ready to play.
	IsReadyToPlay bool `plist:"readyToPlay"`

	// ReadyToPlayValue represents the information on whether content is currently playing, ready to play or not.
	ReadyToPlayValue interface{} `plist:"readyToPlay"`

	// Duration represents playback duration in seconds.
	Duration float64 `plist:"duration"`

	// Position represents playback position in seconds.
	Position float64 `plist:"position"`
}

A PlaybackInfo is a playback information of playing content.

type SlideTransition

type SlideTransition string

SlideTransition represents transition that used when show the picture.

const (
	SlideNone     SlideTransition = "None"
	SlideDissolve SlideTransition = "Dissolve"
	SlideLeft     SlideTransition = "SlideLeft"
	SlideRight    SlideTransition = "SlideRight"
)

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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