joshmcarthur / on-the-spot

A web-controllable searching and queueing system for Spotify
9 stars 4 forks source link

Play Controls #7

Closed joshmcarthur closed 12 years ago

joshmcarthur commented 12 years ago

Sometimes, even when the queue isn't empty, we want to be able to pause and play. We need controls on the page to allow us to Play and Pause the Spotify player from the web interface.

The code for this should be quite easy:

  def pause
    $player.pause
    render :nothing => true
  end
  def play
    $player.play
    render :nothing => true
  end

...but I'm not sure how this will affect the daemon (which blocks while it calls play! on a track). More research needed, but it should be pretty simple.

robotdana commented 12 years ago

+1

joshmcarthur commented 12 years ago

I've nearly finished this, over at https://github.com/joshmcarthur/on-the-spot/tree/feature/7-controls. The clearing queue works, but the web app keeps saying the player is 'stopped' even when it isn't. Regardless, it should be done soon.

joshmcarthur commented 12 years ago

I think I'm going to need to park this for now. I'll try and explain why below:

Right now, I define a Hallon::Player instance as global variable $player, in a setup method. This works fine - I can access a $player from both the web app and the daemon, and can play tracks, etc. on each of those. The problem is that while I can access two player instances, I'm pretty sure they're different. I can play a track with one, and try to play and pause the other one, but nothing happens. In terms of the status, it changes as it should - if I hit 'Play', it changes to :playing and so on, but it doesn't actually do anything.

There's a couple of alternative to how we could do this, but all are a bit complicated. Here's why:

  1. All involve adding latency to these operations - I'd probably have to make a new daemon
  2. Even if it was on a new daemon, I would probably still have the same problem with two instances
  3. I'm unsure of the effect of calling pause during a blocking call play! - which I use to play the track, but I know that the daemon will be harder to control without that blocking call (since it would start trying to play the next track), and that I can't put pause in that daemon either, because it would not try and pause until the blocking call finishes.

So, @dnl (since you've weighed in on this).....any ideas?

joshmcarthur commented 12 years ago

Closed by 339bd754301d71b704c180f4ac21fde2ffada456. I've done the best I can with this so that the player can be muted/unmuted. I think anything more is going to be prohibitively difficult at this point.