0.0
No commit activity in last 3 years
No release in over 3 years
A Ruby wrapper for Mac's `afplay`
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 3.9
 Project Readme

Ruby Afplay

A gem to play audio from the command line using afplay. OS X only!

Installation

Add this line to your application's Gemfile:

gem 'ruby_afplay'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ruby_afplay

Usage

Create a new player instance by passing in a path to an mp3 file:

player = RubyAfplay::Player.new("demo/test.mp3")

The player instance has three methods for interacting with the mp3 player:

player.play  # start/resume playing (and start afplay process)
player.pause # pause playing
player.stop  # stop playing (and kill afplay process)

Here's a simple example of playing/pausing/stopping file from the command line:

player = RubyAfplay::Player.new("demo/test.mp3", volume: 2, time: 10, rate: 0.5)

input = nil
while input != "exit"
  puts `clear`
  puts <<~MENU
  Enter a command to control the audio player. Options: 

  play  |  start playing audio or resume paused audio
  pause |  pause playing audio
  stop  |  stop playing
  exit  |  exit player

  MENU
  print "Your Command: "
  input = gets.chomp

  case input
  when "play"
    player.play
  when "pause"
    player.pause
  when "stop"
    player.stop
  when "exit"
    player.stop
  end
end

puts "TTFN!"