Documentation
¶
Index ¶
- Constants
- func GetFormatBitrate(format metadatapb.AudioFile_Format) int
- type AudioFormat
- type Event
- type EventManager
- type EventType
- type Options
- type Player
- func (p *Player) Close()
- func (p *Player) HasBeenPlayingFor() time.Duration
- func (p *Player) NewStream(ctx context.Context, client *http.Client, spotId librespot.SpotifyId, ...) (*Stream, error)
- func (p *Player) Pause() error
- func (p *Player) Play() error
- func (p *Player) PositionMs() int64
- func (p *Player) Receive() <-chan Event
- func (p *Player) SeekMs(pos int64) error
- func (p *Player) SetPrimaryStream(source librespot.AudioSource, paused, drop bool) error
- func (p *Player) SetSecondaryStream(source librespot.AudioSource)
- func (p *Player) SetVolume(val uint32)
- func (p *Player) Stop()
- type Stream
- type SwitchingAudioSource
- func (s *SwitchingAudioSource) Close() error
- func (s *SwitchingAudioSource) Done() <-chan struct{}
- func (s *SwitchingAudioSource) PositionMs() int64
- func (s *SwitchingAudioSource) Read(p []float32) (n int, err error)
- func (s *SwitchingAudioSource) SetPositionMs(pos int64) error
- func (s *SwitchingAudioSource) SetPrimary(source librespot.AudioSource)
- func (s *SwitchingAudioSource) SetSecondary(source librespot.AudioSource)
Constants ¶
View Source
const ( SampleRate = 44100 Channels = 2 )
View Source
const CdnUrlQuarantineDuration = 15 * time.Minute
View Source
const DisableCheckMediaRestricted = true
View Source
const MaxStateVolume = 65535
Variables ¶
This section is empty.
Functions ¶
func GetFormatBitrate ¶ added in v0.3.0
func GetFormatBitrate(format metadatapb.AudioFile_Format) int
Types ¶
type AudioFormat ¶ added in v0.5.1
type AudioFormat int
const ( AudioFormatUnknown AudioFormat = iota AudioFormatFLAC AudioFormatOGGVorbis AudioFormatMP3 AudioFormatAAC )
func GetAudioFileFormatAudioFormat ¶ added in v0.5.1
func GetAudioFileFormatAudioFormat(format metadatapb.AudioFile_Format) AudioFormat
GetAudioFileFormatAudioFormat maps metadatapb.AudioFile_Format to AudioFormat
type EventManager ¶ added in v0.3.0
type EventManager interface {
PreStreamLoadNew(playbackId []byte, spotId librespot.SpotifyId, mediaPosition int64)
PostStreamResolveAudioFile(playbackId []byte, targetBitrate int32, media *librespot.Media, file *metadata.AudioFile)
PostStreamRequestAudioKey(playbackId []byte)
PostStreamResolveStorage(playbackId []byte)
PostStreamInitHttpChunkReader(playbackId []byte, reader *audio.HttpChunkedReader)
OnPrimaryStreamUnload(stream *Stream, pos int64)
PostPrimaryStreamLoad(stream *Stream, paused bool)
OnPlayerPlay(stream *Stream, ctxUri string, shuffle bool, playOrigin *connectpb.PlayOrigin, track *connectpb.ProvidedTrack, pos int64)
OnPlayerResume(stream *Stream, pos int64)
OnPlayerPause(stream *Stream, ctxUri string, shuffle bool, playOrigin *connectpb.PlayOrigin, track *connectpb.ProvidedTrack, pos int64)
OnPlayerSeek(stream *Stream, oldPos, newPos int64)
OnPlayerSkipForward(stream *Stream, pos int64, skipTo bool)
OnPlayerSkipBackward(stream *Stream, pos int64)
OnPlayerEnd(stream *Stream, pos int64)
Close()
}
type Options ¶ added in v0.2.0
type Options struct {
Spclient *spclient.Spclient
AudioKey *audio.KeyProvider
Events EventManager
Log librespot.Logger
// FlacEnabled specifies if FLAC files should be preferred when available.
// When setting this to true, it is assumed that the PlayPlay plugin is provided.
FlacEnabled bool
// NormalisationEnabled specifies if the volume should be normalised according
// to Spotify parameters. Only track normalization is supported.
NormalisationEnabled bool
// NormalisationUseAlbumGain specifies whether album gain instead of track gain
// should be used for normalisation
NormalisationUseAlbumGain bool
// NormalisationPregain specifies the pre-gain to apply when normalising the volume
// in dB. Use negative values to avoid clipping.
NormalisationPregain float32
// CountryCode specifies the country code to use for media restrictions.
CountryCode *string
// AudioBackend specifies the audio backend to use (alsa, pulseaudio, etc).
AudioBackend string
// AudioDevice specifies the audio device name.
//
// This feature is support only for the alsa backend.
AudioDevice string
// MixerDevice specifies the audio mixer name.
//
// This feature is support only for the alsa backend.
MixerDevice string
// MixerControlName specifies the mixer control name.
//
// This only works in combination with Mixer.
MixerControlName string
// AudioBufferTime is the buffer time in microseconds.
//
// This is only supported on the alsa backend.
AudioBufferTime int
// AudioPeriodCount is the number of periods to request.
//
// This is only supported on the alsa backend.
AudioPeriodCount int
// ExternalVolume specifies, if the volume is controlled outside the app.
//
// This is only supported on the alsa and pipe backends.
// The PulseAudio backend always uses external volume.
ExternalVolume bool
// VolumeUpdate is a channel on which volume updates will be sent back to
// Spotify. This must be a buffered channel.
VolumeUpdate chan float32
// AudioOutputPipe is the path to the output pipe.
//
// This is only supported on the pipe backend.
AudioOutputPipe string
// AudioOutputPipeFormat is the format of the output pipe.
// Available formats are: "s16le", "s32le", "f32le". Default is "s16le".
//
// This is only supported on the pipe backend.
AudioOutputPipeFormat string
}
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
func (*Player) HasBeenPlayingFor ¶
func (*Player) PositionMs ¶
func (*Player) SetPrimaryStream ¶
func (p *Player) SetPrimaryStream(source librespot.AudioSource, paused, drop bool) error
func (*Player) SetSecondaryStream ¶
func (p *Player) SetSecondaryStream(source librespot.AudioSource)
type Stream ¶
type Stream struct {
PlaybackId []byte
Source librespot.AudioSource
Media *librespot.Media
File *metadatapb.AudioFile
}
type SwitchingAudioSource ¶
type SwitchingAudioSource struct {
// contains filtered or unexported fields
}
func NewSwitchingAudioSource ¶
func NewSwitchingAudioSource() *SwitchingAudioSource
func (*SwitchingAudioSource) Close ¶
func (s *SwitchingAudioSource) Close() error
func (*SwitchingAudioSource) Done ¶
func (s *SwitchingAudioSource) Done() <-chan struct{}
func (*SwitchingAudioSource) PositionMs ¶
func (s *SwitchingAudioSource) PositionMs() int64
func (*SwitchingAudioSource) Read ¶
func (s *SwitchingAudioSource) Read(p []float32) (n int, err error)
func (*SwitchingAudioSource) SetPositionMs ¶
func (s *SwitchingAudioSource) SetPositionMs(pos int64) error
func (*SwitchingAudioSource) SetPrimary ¶
func (s *SwitchingAudioSource) SetPrimary(source librespot.AudioSource)
func (*SwitchingAudioSource) SetSecondary ¶
func (s *SwitchingAudioSource) SetSecondary(source librespot.AudioSource)
Click to show internal directories.
Click to hide internal directories.