Class: Soundcloud9000::Controllers::PlayerController
- Inherits:
-
Controller
- Object
- Controller
- Soundcloud9000::Controllers::PlayerController
- Defined in:
- lib/soundcloud9000/controllers/player_controller.rb
Overview
The top section player controller Displays current track position Equalizer and track information
Instance Attribute Summary
Attributes inherited from Controller
Instance Method Summary collapse
-
#initialize(view, client) ⇒ PlayerController
constructor
A new instance of PlayerController.
- #play(track) ⇒ Object
Methods inherited from Controller
Constructor Details
#initialize(view, client) ⇒ PlayerController
Returns a new instance of PlayerController.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/soundcloud9000/controllers/player_controller.rb', line 11 def initialize(view, client) super(view) @client = client @player = Models::Player.new @player.events.on(:progress) do @view.render end @player.events.on(:complete) do events.trigger(:complete) end @view.player = @player events.on(:key) do |key| if @player. case key when :left @player.rewind when :right @player.forward when :one @player.seek_position(1) when :two @player.seek_position(2) when :three @player.seek_position(3) when :four @player.seek_position(4) when :five @player.seek_position(5) when :six @player.seek_position(6) when :seven @player.seek_position(7) when :eight @player.seek_position(8) when :nine @player.seek_position(9) end end if key == :space if @player.track @player.toggle @view.render end end end end |
Instance Method Details
#play(track) ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/soundcloud9000/controllers/player_controller.rb', line 63 def play(track) if track.nil? UI::Input.error('No track currently selected. Use f to switch to '\ "#{@client.current_user.username}'s favorites, or"\ ' s to switch to their playlists/sets.') else location = @client.location(track.stream_url) @player.play(track, location) end end |