Module: Mixin::Audio

Included in:
Pomodoro
Defined in:
lib/fox/interface/thor/mixin/audio.rb

Instance Method Summary collapse

Instance Method Details

#initialize(*args) ⇒ Object

Parameters:

  • args (Array)

    Argument array



21
22
23
# File 'lib/fox/interface/thor/mixin/audio.rb', line 21

def initialize *args
  super
end

#play_local(file) ⇒ Object

Parameters:

  • file (String)

    Filename incl. path



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/fox/interface/thor/mixin/audio.rb', line 37

def play_local file

  duration = get_duration( file ) # in sec

  if( duration.nil? )
    play( file, :file )
  else

    threads     = []

    threads     <<  Thread.new { play( file, :file ) }
    threads     <<  Thread.new do
      ProgressBar.new( "Pomodoro", duration.to_i ) do |bar|
        duration.to_i.times { sleep(1); bar.inc }
      end
    end

    threads.each { |thread| thread.join }

  end # if( duration.nil? )

end

#play_remote(url) ⇒ Object

Parameters:

  • url (String)

    Remote URL



29
30
31
# File 'lib/fox/interface/thor/mixin/audio.rb', line 29

def play_remote url
  play( url, :url )
end