audio

package
v3.0.13 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const AllDTMF = "0123456789ABCD*#"

AllDTMF is a string which contains all possible DTMF digits.

Variables

View Source
var Logger = log15.New()

Logger defaults to a discard handler (null output). If you wish to enable logging, you can set your own handler like so:

ari.Logger.SetHandler(log15.StderrHandler)
View Source
var MaxPlaybackTime = 10 * time.Minute

MaxPlaybackTime is the maximum amount of time to allow for a playback to complete.

View Source
var PlaybackStartTimeout = 1 * time.Second

PlaybackStartTimeout is the time to allow for Asterisk to send the PlaybackStarted before giving up.

Functions

This section is empty.

Types

type Options

type Options struct {
	// ID is an optional ID to use for the playback's ID. If one
	// is not supplied, an ID will be randomly generated internally.
	// NOTE that this ID will only be used for the FIRST playback
	// in a queue.  All subsequent playback IDs will be randomly generated.
	ID string

	// ExitOnDTMF defines a list of DTMF digits on receipt of which will
	// terminate the playback of the queue.  You may set this to AllDTMF
	// in order to match any DTMF digit.
	ExitOnDTMF string

	// Done is an optional channel for receiving notification when the playback
	// is complete.  This is useful if the playback is to be executed asynchronously.
	// This channel will be closed by the playback when playback the is complete.
	Done chan<- struct{}
}

Options describes various options which are available to playback operations.

type Playback

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

A Playback is a lifecycle managed audio object

func PlayAsync

func PlayAsync(ctx context.Context, p Player, mediaURI string) *Playback

PlayAsync plays the audio asynchronously and returns a playback object

func (*Playback) Cancel

func (p *Playback) Cancel()

Cancel stops the playback

func (*Playback) Err

func (p *Playback) Err() error

Err returns any accumulated errors during playback

func (*Playback) Handle

func (p *Playback) Handle() *ari.PlaybackHandle

Handle returns the ARI reference to the playback object

func (*Playback) Started

func (p *Playback) Started() <-chan struct{}

Started returns the channel that is closed when the playback has started

func (*Playback) Status

func (p *Playback) Status() Status

Status returns the current status of the playback

func (*Playback) Stopped

func (p *Playback) Stopped() <-chan struct{}

Stopped returns the channel that is closed when the playback has stopped

type Player

type Player interface {
	ari.Subscriber

	// Play plays the audio using the given playback ID and media URI
	Play(string, string) (*ari.PlaybackHandle, error)
}

A Player is an entity which can have an audio URI played and can have event subscriptions

type Queue

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

Queue represents a sequence of audio playbacks which are to be played on the associated Player

func NewQueue

func NewQueue() *Queue

NewQueue creates (but does not start) a new playback queue.

func (*Queue) Add

func (pq *Queue) Add(mediaURIs ...string)

Add appends one or more mediaURIs to the playback queue

func (*Queue) Flush

func (pq *Queue) Flush()

Flush empties a playback queue. NOTE that this does NOT stop the current playback.

func (*Queue) Play

func (pq *Queue) Play(ctx context.Context, p Player, opts *Options) (Status, error)

Play starts the playback of the queue to the Player.

func (*Queue) ReceivedDTMF

func (pq *Queue) ReceivedDTMF() string

ReceivedDTMF returns any DTMF which has been received by the PlaybackQueue.

type Status

type Status int

Status indicates the status of the prompt operation.

const (
	// InProgress indicates that the audio is currently playing
	InProgress Status = iota

	// Finished indicates that the audio playback finished successfully
	Finished

	// Canceled indicates that the audio was canceled
	Canceled

	// Timeout indicates that audio playback timed out
	Timeout

	// Hangup indicates that the audio was interrupted by hangup
	Hangup

	// Failed indicates that the audio playback failed
	Failed
)

func Play

func Play(ctx context.Context, p Player, mediaURI string) (st Status, err error)

Play plays the given media URI

func (Status) String

func (i Status) String() string

Directories

Path Synopsis
Package audiouri provides conversions for common sounds to asterisk-supported audio URIs
Package audiouri provides conversions for common sounds to asterisk-supported audio URIs

Jump to

Keyboard shortcuts

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