Skip to content

Instantly share code, notes, and snippets.

@electronicbites
Created April 26, 2012 15:23
Show Gist options
  • Save electronicbites/2500330 to your computer and use it in GitHub Desktop.
Save electronicbites/2500330 to your computer and use it in GitHub Desktop.
def send_events_for_song_change(user, old_song, new_song)
timenow = Time.now.to_i
EventSender.send_user_played_song(user, old_song, timenow)
EventSender.send_user_started_playing_song(user, new_song, timenow)
end
playlist.started_at = Time.now
playlist.save
user.last_request_at = Time.now
user.become_host
old_current_song = nil
current_song = 42 ##dummy not nil value
while (current_song)
current_song = playlist.find_track_playing_at
if (current_song && current_song != old_current_song)
puts "new media for #{user.name}"
send_events_for_song_change(user, old_current_song, current_song)
old_current_song = current_song
end
sleep(1)
user.last_request_at = Time.now
user.save
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment