💾 Archived View for gem.sdf.org › s.kaplan › cheatsheets › commandline-tools › afplay.md captured on 2024-03-21 at 15:42:07.

View Raw

More Information

⬅️ Previous capture (2023-09-08)

-=-=-=-=-=-=-

# afplay Cheatsheet

## Overview

afplay is a command-line audio player for macOS. It allows you to play audio files from the command line or from a 
script.

## Usage

afplay [options] audio_file


## Options

- `-v volume`: Set the playback volume (0.0 - 1.0).
- `-t time`: Play the audio file for a specific duration (in seconds).
- `-r rate`: Play the audio file at a specific sample rate.
- `-h`: Display help information.

## Examples

Play an audio file:

afplay audio_file.mp3


Play an audio file with reduced volume:

afplay -v 0.5 audio_file.mp3


Play an audio file for 30 seconds:

afplay -t 30 audio_file.mp3


## Resources

- [afplay Man Page](https://ss64.com/osx/afplay.html)