Class: MikePlayer::PlayThread
- Inherits:
-
Object
- Object
- MikePlayer::PlayThread
- Defined in:
- lib/mikeplayer/executable.rb,
lib/mikeplayer/play_thread.rb
Class Method Summary collapse
Instance Method Summary collapse
- #info ⇒ Object
-
#initialize(filename) ⇒ PlayThread
constructor
A new instance of PlayThread.
- #to_json ⇒ Object
Constructor Details
#initialize(filename) ⇒ PlayThread
Returns a new instance of PlayThread.
3 4 5 6 |
# File 'lib/mikeplayer/executable.rb', line 3 def initialize(filename) @filename = filename @mp3info = Mp3Info.new(filename) end |
Class Method Details
.run(file, volume) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/mikeplayer/play_thread.rb', line 3 def self.run(file, volume) args = [ :play, '--no-show-progress', '--volume', volume, song ] Open3.popen2e(*args) do |stdin, out, wait_thr| end end |
Instance Method Details
#info ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/mikeplayer/executable.rb', line 8 def info artist = "#{@mp3info.tag.artist}" title = "#{@mp3info.tag.title}" if (true == artist.empty?) && (true == title.empty?) return File.basename(filename, '.mp3') elsif (true == artist.empty?) artist = "?????" elsif (true == title.empty?) title = "?????" end return "#{artist} - #{title}" end |
#to_json ⇒ Object
23 24 25 |
# File 'lib/mikeplayer/executable.rb', line 23 def to_json return @filename end |