start of new simplified player interface
This commit is contained in:
@@ -193,6 +193,19 @@ func (p *Player) ClearPlayQueue() error {
|
|||||||
return p.mpv.Command([]string{"playlist-clear"})
|
return p.mpv.Command([]string{"playlist-clear"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *Player) SetFile(url string) error {
|
||||||
|
if !p.initialized {
|
||||||
|
return ErrUnitialized
|
||||||
|
}
|
||||||
|
if err := p.mpv.Command([]string{"stop"}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := p.mpv.Command([]string{"playlist-clear"}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return p.mpv.Command([]string{"loadfile", url, "append"})
|
||||||
|
}
|
||||||
|
|
||||||
// Seeks within the currently playing track.
|
// Seeks within the currently playing track.
|
||||||
// See MPV seek command documentation for more details.
|
// See MPV seek command documentation for more details.
|
||||||
func (p *Player) SeekSeconds(secs float64) error {
|
func (p *Player) SeekSeconds(secs float64) error {
|
||||||
|
|||||||
@@ -7,11 +7,23 @@ type URLPlayer interface {
|
|||||||
AppendFile(url string) error
|
AppendFile(url string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type URLPlayerNew interface {
|
||||||
|
BasePlayer
|
||||||
|
SetFile(url string)
|
||||||
|
SetNextFile(url string)
|
||||||
|
}
|
||||||
|
|
||||||
type TrackPlayer interface {
|
type TrackPlayer interface {
|
||||||
BasePlayer
|
BasePlayer
|
||||||
AppendTrack(track *mediaprovider.Track) error
|
AppendTrack(track *mediaprovider.Track) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TrackPlayerNew interface {
|
||||||
|
BasePlayer
|
||||||
|
SetTrack(track *mediaprovider.Track) error
|
||||||
|
SetNextTrack(track *mediaprovider.Track) error
|
||||||
|
}
|
||||||
|
|
||||||
type BasePlayer interface {
|
type BasePlayer interface {
|
||||||
// Transport
|
// Transport
|
||||||
PlayTrackAt(idx int) error
|
PlayTrackAt(idx int) error
|
||||||
@@ -42,6 +54,27 @@ type BasePlayer interface {
|
|||||||
OnTrackChange(func(int))
|
OnTrackChange(func(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type BasePlayerNew interface {
|
||||||
|
Continue() error
|
||||||
|
Pause() error
|
||||||
|
Stop() error
|
||||||
|
|
||||||
|
SeekSeconds(secs float64) error
|
||||||
|
IsSeeking() bool
|
||||||
|
|
||||||
|
SetVolume(int) error
|
||||||
|
GetVolume() int
|
||||||
|
|
||||||
|
GetStatus() Status
|
||||||
|
|
||||||
|
// Event API
|
||||||
|
OnPaused(func())
|
||||||
|
OnStopped(func())
|
||||||
|
OnPlaying(func())
|
||||||
|
OnSeek(func())
|
||||||
|
OnTrackChange(func(int))
|
||||||
|
}
|
||||||
|
|
||||||
type ReplayGainPlayer interface {
|
type ReplayGainPlayer interface {
|
||||||
SetReplayGainOptions(ReplayGainOptions) error
|
SetReplayGainOptions(ReplayGainOptions) error
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user