shutdown proxy server when switching back to local; debounce vol slider
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/dweymouth/supersonic/backend/mediaprovider"
|
||||
"github.com/dweymouth/supersonic/backend/player"
|
||||
"github.com/dweymouth/supersonic/backend/player/mpv"
|
||||
"github.com/dweymouth/supersonic/backend/util"
|
||||
"github.com/dweymouth/supersonic/sharedutil"
|
||||
)
|
||||
@@ -154,6 +155,9 @@ func (p *playbackEngine) SetPlayer(pl player.BasePlayer) {
|
||||
}
|
||||
|
||||
oldVol := p.player.GetVolume()
|
||||
if _, isMPV := p.player.(*mpv.Player); !isMPV {
|
||||
p.player.Destroy()
|
||||
}
|
||||
p.player = pl
|
||||
p.registerPlayerCallbacks(pl)
|
||||
|
||||
|
||||
@@ -197,6 +197,12 @@ func (d *DLNAPlayer) GetStatus() player.Status {
|
||||
}
|
||||
}
|
||||
|
||||
func (d *DLNAPlayer) Destroy() {
|
||||
if d.proxyServer != nil {
|
||||
go d.proxyServer.Shutdown(context.Background())
|
||||
}
|
||||
}
|
||||
|
||||
func getLocalIP() (string, error) {
|
||||
interfaces, err := net.Interfaces()
|
||||
if err != nil {
|
||||
|
||||
@@ -140,6 +140,8 @@ func (j *JukeboxPlayer) GetStatus() player.Status {
|
||||
}
|
||||
}
|
||||
|
||||
func (j *JukeboxPlayer) Destroy() {}
|
||||
|
||||
func (j *JukeboxPlayer) startAndUpdateTime() error {
|
||||
beforeStart := time.Now()
|
||||
if err := j.provider.JukeboxStart(); err != nil {
|
||||
|
||||
@@ -27,6 +27,8 @@ type BasePlayer interface {
|
||||
|
||||
GetStatus() Status
|
||||
|
||||
Destroy()
|
||||
|
||||
// Event API
|
||||
OnPaused(func())
|
||||
OnStopped(func())
|
||||
|
||||
Reference in New Issue
Block a user