Class: RubyAfplay::Player
- Inherits:
-
Object
- Object
- RubyAfplay::Player
- Defined in:
- lib/ruby_afplay/player.rb
Instance Method Summary collapse
-
#initialize(file_path, options = {}) ⇒ Player
constructor
A new instance of Player.
- #pause ⇒ Object
- #play ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(file_path, options = {}) ⇒ Player
Returns a new instance of Player.
4 5 6 |
# File 'lib/ruby_afplay/player.rb', line 4 def initialize(file_path, = {}) @command = file_path + () end |
Instance Method Details
#pause ⇒ Object
17 18 19 20 |
# File 'lib/ruby_afplay/player.rb', line 17 def pause # send a stop signal to afplay using the process_id Process.kill("SIGSTOP", @process_id) end |
#play ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/ruby_afplay/player.rb', line 8 def play if @process_id # resume playing if the process is already running Process.kill("SIGCONT", @process_id) else start_process! end end |
#stop ⇒ Object
22 23 24 25 26 27 |
# File 'lib/ruby_afplay/player.rb', line 22 def stop # send a kill signal to aflpay using the process_id Process.kill("SIGKILL", @process_id) # detach the process detach_process! end |