Sha256: 0626c0a926eb7db88a565002e2693a314b8c455b2bcd811929569b5367345638
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
require 'radiodan/event_binding' class Radiodan class Player include Logging include EventBinding attr_reader :adapter, :state def initialize @state = State.new(:playback => 'stopped') end def adapter=(adapter) @adapter = adapter @adapter.player = self end def adapter? !adapter.nil? end def state=(new_state) @state = new_state trigger_event(:state, @state) @state end =begin Sync checks the current status of the player. Is it paused? Playing? What is it playing? It compares the expected to actual statuses and makes changes required to keep them the same. =end def sync current_state = adapter.state expected_state = state # playlist unless expected_state.content.files.include?(current_state.file) logger.debug "Expected: #{expected_state.content.files.first} Got: #{current_state.file}" trigger_event :playlist, expected_state.content end # playback state unless expected_state.playback == current_state.state logger.debug "Expected: #{expected_state.playback} Got: #{current_state.state}" trigger_event expected_state.playback end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
radiodan-0.0.1 | lib/radiodan/player.rb |