Skip to content

Commit

Permalink
Fix auto-enabling of play button when callback calls are not available
Browse files Browse the repository at this point in the history
  • Loading branch information
alexballas committed Jun 2, 2023
1 parent 88c6862 commit c9be6dd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 34 deletions.
6 changes: 3 additions & 3 deletions httphandlers/httphandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ func (s *HTTPserver) callbackHandler(tv *soapcalls.TVPayload, screen Screen) htt

switch newstate {
case "PLAYING":
screen.EmitMsg("Playing")
tv.SetProcessStopTrue(uuid)
// screen.EmitMsg("Playing")
// tv.SetProcessStopTrue(uuid)
case "PAUSED_PLAYBACK":
screen.EmitMsg("Paused")
// screen.EmitMsg("Paused")
case "STOPPED":
screen.EmitMsg("Stopped")
_ = tv.UnsubscribeSoapCall(uuid)
Expand Down
33 changes: 2 additions & 31 deletions internal/gui/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,37 +438,6 @@ out:
}

func pauseAction(screen *NewScreen) {
if screen.cancelEnablePlay != nil {
screen.cancelEnablePlay()
}

ctx, cancelEnablePlay := context.WithTimeout(context.Background(), 5*time.Second)
screen.cancelEnablePlay = cancelEnablePlay

go func() {
<-ctx.Done()

defer func() { screen.cancelEnablePlay = nil }()

if errors.Is(ctx.Err(), context.Canceled) {
return
}

out, err := screen.tvdata.GetTransportInfo()
if err != nil {
return
}

switch out[0] {
case "PLAYING":
setPlayPauseView("Pause", screen)
screen.updateScreenState("Playing")
case "PAUSED_PLAYBACK":
setPlayPauseView("Play", screen)
screen.updateScreenState("Paused")
}
}()

err := screen.tvdata.SendtoTV("Pause")
check(screen, err)
}
Expand Down Expand Up @@ -501,6 +470,8 @@ func skipNextAction(screen *NewScreen) {
}

stopAction(screen)
fmt.Println("?edw2")

playAction(screen)
}

Expand Down

0 comments on commit c9be6dd

Please sign in to comment.