playback

package
v0.52.5 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: GPL-3.0 Imports: 10 Imported by: 1

Documentation

Overview

Package playback implements audio playback using PlaybackDevices. It is used to implement the Jukebox mode in turn. It makes use of the MPV library to do the playback. Major parts are: - decoder which includes decoding and transcoding of various audio file formats - device implementing the basic functions to work with audio devices like set, play, stop, skip, ... - queue a simple playlist

Index

Constants

View Source
const DefaultGain float32 = 1.0

Variables

This section is empty.

Functions

func NewPlaybackDevice

func NewPlaybackDevice(ctx context.Context, playbackServer PlaybackServer, name string, deviceName string) *playbackDevice

NewPlaybackDevice creates a new playback device which implements all the basic Jukebox mode commands defined here: http://www.subsonic.org/pages/api.jsp#jukeboxControl Starts the trackSwitcher goroutine for the device.

Types

type DeviceStatus

type DeviceStatus struct {
	CurrentIndex int
	Playing      bool
	Gain         float32
	Position     int
}

type PlaybackServer

type PlaybackServer interface {
	Run(ctx context.Context) error
	GetDeviceForUser(user string) (*playbackDevice, error)
	GetMediaFile(id string) (*model.MediaFile, error)
}

func GetInstance

func GetInstance(ds model.DataStore) PlaybackServer

GetInstance returns the playback-server singleton

type Queue

type Queue struct {
	Index int
	Items model.MediaFiles
}

func NewQueue

func NewQueue() *Queue

func (*Queue) Add

func (pd *Queue) Add(items model.MediaFiles)

adding mediafiles to the queue

func (*Queue) Clear

func (pd *Queue) Clear()

empties whole queue

func (*Queue) Current

func (pd *Queue) Current() *model.MediaFile

returns the current mediafile or nil

func (*Queue) Get

func (pd *Queue) Get() model.MediaFiles

returns the whole queue

func (*Queue) IncreaseIndex

func (pd *Queue) IncreaseIndex()

Goto next index

func (*Queue) IsAtLastElement

func (pd *Queue) IsAtLastElement() bool

Are we at the last track?

func (*Queue) IsEmpty

func (pd *Queue) IsEmpty() bool

func (*Queue) Remove

func (pd *Queue) Remove(idx int)

idx Zero-based index of the song to skip to or remove.

func (*Queue) Set

func (pd *Queue) Set(items model.MediaFiles)

set is similar to a clear followed by a add, but will not change the currently playing track.

func (*Queue) SetIndex

func (pd *Queue) SetIndex(idx int)

Sets the index to a new, valid value inside the Items. Values lower than zero are going to be zero, values above will be limited by number of items.

func (*Queue) Shuffle

func (pd *Queue) Shuffle()

func (*Queue) Size

func (pd *Queue) Size() int

func (*Queue) String

func (pd *Queue) String() string

type Track

type Track interface {
	IsPlaying() bool
	SetVolume(value float32) // Used to control the playback volume. A float value between 0.0 and 1.0.
	Pause()
	Unpause()
	Position() int
	SetPosition(offset int) error
	Close()
	String() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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