disable cast button while player switch in progress
This commit is contained in:
@@ -142,6 +142,10 @@ func (p *playbackEngine) registerPlayerCallbacks(pl player.BasePlayer) {
|
||||
}
|
||||
|
||||
func (p *playbackEngine) SetPlayer(pl player.BasePlayer) error {
|
||||
// even if we don't successfully change players,
|
||||
// make sure UI updates if needed (eg enabling cast button)
|
||||
defer p.invokeNoArgCallbacks(p.onPlayerChange)
|
||||
|
||||
needToUnpause := false
|
||||
|
||||
stat := p.PlayerStatus()
|
||||
|
||||
@@ -151,10 +151,11 @@ func (m *Controller) HaveModal() bool {
|
||||
return m.haveModal
|
||||
}
|
||||
|
||||
func (m *Controller) ShowCastMenu() {
|
||||
func (m *Controller) ShowCastMenu(onPendingPlayerChange func()) {
|
||||
rp := m.App.PlaybackManager.CurrentRemotePlayer()
|
||||
devices := m.App.PlaybackManager.RemotePlayers()
|
||||
local := fyne.NewMenuItem(lang.L("Local player"), func() {
|
||||
onPendingPlayerChange()
|
||||
go func() {
|
||||
if err := m.App.PlaybackManager.SetRemotePlayer(nil); err != nil {
|
||||
fyne.Do(func() { m.ToastProvider.ShowErrorToast("Failed to disconnect from remote player") })
|
||||
@@ -168,6 +169,7 @@ func (m *Controller) ShowCastMenu() {
|
||||
for _, d := range devices {
|
||||
_d := d
|
||||
item := fyne.NewMenuItem(d.Name, func() {
|
||||
onPendingPlayerChange()
|
||||
go func() {
|
||||
if err := m.App.PlaybackManager.SetRemotePlayer(&_d); err != nil {
|
||||
fyne.Do(func() { m.ToastProvider.ShowErrorToast("Failed to connect to " + _d.Name) })
|
||||
|
||||
@@ -98,7 +98,12 @@ func (a *AuxControls) SetLoopMode(mode backend.LoopMode) {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *AuxControls) DisableCastButton() {
|
||||
a.cast.Disable()
|
||||
}
|
||||
|
||||
func (a *AuxControls) SetIsRemotePlayer(isRemote bool) {
|
||||
a.cast.Enable()
|
||||
a.cast.Highlighted = isRemote
|
||||
a.cast.Refresh()
|
||||
}
|
||||
@@ -115,8 +120,10 @@ func (a *AuxControls) OnShowPlayQueue(f func()) {
|
||||
a.showQueue.OnTapped = f
|
||||
}
|
||||
|
||||
func (a *AuxControls) OnShowCastMenu(f func()) {
|
||||
a.cast.OnTapped = f
|
||||
func (a *AuxControls) OnShowCastMenu(f func(func())) {
|
||||
a.cast.OnTapped = func() {
|
||||
f(a.DisableCastButton)
|
||||
}
|
||||
}
|
||||
|
||||
type volumeSlider struct {
|
||||
|
||||
Reference in New Issue
Block a user