Class: Segue::PlayerController

Inherits:
Object
  • Object
show all
Defined in:
lib/segue/player_controller.rb

Constant Summary collapse

CROSSFADE_TRIGGER_SECONDS =
5

Instance Method Summary collapse

Constructor Details

#initializePlayerController

Returns a new instance of PlayerController.



12
13
14
15
16
17
18
19
# File 'lib/segue/player_controller.rb', line 12

def initialize
  @player = Segue::Player.new
  @preferences = Segue::Preferences.new
  @queue = Segue::Queue.new
  @notifiers = Segue::Notifiers.new
  @track = nil
  @suspended = false
end

Instance Method Details

#cleanupObject

rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity



36
37
38
39
40
# File 'lib/segue/player_controller.rb', line 36

def cleanup
  @notifiers.track_suspended
  @player.fadeout
  @player.cleanup
end

#nextObject

An ordered chain of guard clauses - the priority between them is the point, so leave it flat rather than nesting it to please the metrics rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity



24
25
26
27
28
29
30
31
32
33
# File 'lib/segue/player_controller.rb', line 24

def next
  return on_play if @preferences.play? && @suspended
  return on_pause if @preferences.pause? && !@suspended
  return on_stop if @preferences.stop? && !@suspended
  return build if @suspended
  return when_playing if @track && @player.playing?
  return when_auto if @preferences.continue?

  when_manual
end