Class: Commands::Play

Inherits:
Object
  • Object
show all
Defined in:
lib/commands/play.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, settings) ⇒ Play

Returns a new instance of Play.



5
6
7
# File 'lib/commands/play.rb', line 5

def initialize(args, settings)
  @app = args.first || Helpers::Player.to_s || settings.get('default_player')
end

Class Method Details

.matchesObject



24
25
26
# File 'lib/commands/play.rb', line 24

def self.matches
  ['play', 'play my music']
end

Instance Method Details

#goObject



9
10
11
12
13
# File 'lib/commands/play.rb', line 9

def go
  `osascript -e 'tell application "#{@app}" to launch'`
  sleep 1.5
  `osascript -e 'tell application "#{@app}" to play'`
end

#media?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/commands/play.rb', line 20

def media?
  false
end

#respondObject



15
16
17
18
# File 'lib/commands/play.rb', line 15

def respond
  sleep 3.5
  "Now playing: #{`osascript -e 'tell application "#{@app}" to get the name of the current track'`}".chomp rescue ""
end