Class: Commands::Play
- Inherits:
-
Object
- Object
- Commands::Play
- Defined in:
- lib/commands/play.rb
Class Method Summary collapse
Instance Method Summary collapse
- #go ⇒ Object
-
#initialize(args, settings) ⇒ Play
constructor
A new instance of Play.
- #media? ⇒ Boolean
- #respond ⇒ Object
Constructor Details
#initialize(args, settings) ⇒ Play
Returns a new instance of Play.
3 4 5 |
# File 'lib/commands/play.rb', line 3 def initialize(args, settings) @app = args.first || settings.get('default_player') end |
Class Method Details
.matches ⇒ Object
21 22 23 |
# File 'lib/commands/play.rb', line 21 def self.matches ['play', 'play my music'] end |
Instance Method Details
#go ⇒ Object
7 8 9 10 11 |
# File 'lib/commands/play.rb', line 7 def go `osascript -e 'tell application "#{@app}" to launch'` sleep 1 `osascript -e 'tell application "#{@app}" to play'` end |
#media? ⇒ Boolean
17 18 19 |
# File 'lib/commands/play.rb', line 17 def media? false end |
#respond ⇒ Object
13 14 15 |
# File 'lib/commands/play.rb', line 13 def respond "Now playing: #{`osascript -e 'tell application "#{@app}" to get the name of the current track'`}".chomp rescue "" end |