Class: MusicBlender::Player
- Inherits:
-
Object
- Object
- MusicBlender::Player
- Defined in:
- lib/music_blender/player.rb
Constant Summary collapse
- PLAYING_STATUS_CODE_MAP =
{ -1 => 'Started', 0 => 'Stopped', 1 => 'Paused', 2 => 'Resumed', }
- METHODS_DELEGATED_TO_MONITOR =
[ :frames, :frames_remaining, :playing, :seconds, :seconds_remaining, :song_name, :stop_pause_status ]
Instance Attribute Summary collapse
-
#current_track ⇒ Object
readonly
Returns the value of attribute current_track.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdin ⇒ Object
readonly
Returns the value of attribute stdin.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
-
#initialize ⇒ Player
constructor
A new instance of Player.
- #pause ⇒ Object
- #play ⇒ Object
- #quit ⇒ Object
- #status_string ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize ⇒ Player
Returns a new instance of Player.
29 30 31 32 33 34 |
# File 'lib/music_blender/player.rb', line 29 def initialize @stdin, @stdout, @stderr, @wait_thread = Open3.popen3('mpg123 --rva-mix -R') @logger = Logger.new("#{BLENDER_ROOT}/log/player.log", 10, 1024000) Thread.new { monitor.run } end |
Instance Attribute Details
#current_track ⇒ Object (readonly)
Returns the value of attribute current_track.
21 22 23 |
# File 'lib/music_blender/player.rb', line 21 def current_track @current_track end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
21 22 23 |
# File 'lib/music_blender/player.rb', line 21 def logger @logger end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
21 22 23 |
# File 'lib/music_blender/player.rb', line 21 def stderr @stderr end |
#stdin ⇒ Object (readonly)
Returns the value of attribute stdin.
21 22 23 |
# File 'lib/music_blender/player.rb', line 21 def stdin @stdin end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
21 22 23 |
# File 'lib/music_blender/player.rb', line 21 def stdout @stdout end |
Instance Method Details
#pause ⇒ Object
41 42 43 |
# File 'lib/music_blender/player.rb', line 41 def pause stdin.puts 'PAUSE' end |
#play ⇒ Object
36 37 38 39 |
# File 'lib/music_blender/player.rb', line 36 def play set_current_track_last_played_at stdin.puts "LOAD #{pick_a_track.full_path}" end |
#quit ⇒ Object
49 50 51 |
# File 'lib/music_blender/player.rb', line 49 def quit stdin.puts 'QUIT' end |
#status_string ⇒ Object
53 54 55 |
# File 'lib/music_blender/player.rb', line 53 def status_string PLAYING_STATUS_CODE_MAP[stop_pause_status] end |
#stop ⇒ Object
45 46 47 |
# File 'lib/music_blender/player.rb', line 45 def stop stdin.puts 'STOP' end |