class Spty::Command::PlayCommand

Constants

ASCRIPT_PLAYER_PLAY

Public Class Methods

call(options, _) click to toggle source
# File lib/spty/commands/play_command.rb, line 8
def self.call(options, _)
  return unless running?

  # Get the player state
  player_state_script = Spty::Command::StateCommand::ASCRIPT_PLAYER_STATE
  player_state = Spty::AppleScriptRunner.(player_state_script)

  if player_state.strip == 'paused'
    Spty::AppleScriptRunner.call(ASCRIPT_PLAYER_PLAY)
  end

  track_info_script = Spty::Command::InfoCommand::ASCRIPT_TRACK_INFO
  track_info = Spty::AppleScriptRunner.(track_info_script)

  puts "=> #{track_info.strip} [playing]"
end