Skip to content

Instantly share code, notes, and snippets.

@BrianMMcClain
Created May 9, 2013 03:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrianMMcClain/5545400 to your computer and use it in GitHub Desktop.
Save BrianMMcClain/5545400 to your computer and use it in GitHub Desktop.
Example usage of the Hallon gem to login to Spotify, search for tracks and play a song
require 'hallon'
require 'hallon/openal'
session = Hallon::Session.initialize IO.read('./spotify_appkey.key')
session.login!('johndoe', 'superpassword')
search = Hallon::Search.new("Daft Punk Get Lucky")
search.load
tracks = search.tracks[0...5].map(&:load)
puts "Top 5 Results"
tracks.each do |track|
puts "#{track.artist.name} - #{track.name}"
end
player = Hallon::Player.new(Hallon::OpenAL)
player.play!(tracks.first)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment