Giter Club home page Giter Club logo

afplay's Introduction

Afplay - Apple's Audio File Play wrapper for Node.js

NPM Version Build Status

Afplay is a wrapper for Apple's Audio File Play (afplay).

Use Afplay to play audio files on OS X via afplay. Afplay afplay!

Installation

Afplay was written for Node.js 4+.

npm install --save afplay

Usage

Afplay is super simple to use!

Play a Local File

let Afplay = require('afplay');

// Instantiate a new player
let player = new Afplay;

// Play a sound, handle result within a Promise
player.play('/tmp/my-file.mp3')
  .then(() => {
    console.log('Audio done playing');
  })
  .catch(error => {
    console.log('Error playing file');
  });

Configure Volume & Play Time

It is possible to configure volume and play time (in seconds).

player.play('/tmp/my-file.mp3', {volume: 100, time: 15})
  .then(() => {
    console.log('Loud, short duration audio done playing');
  })
  .catch(error => {
  	console.log('Error playing file');
  });

Examples

View the examples directory.

License

This software is licensed under the MIT License. View the license.

Copyright © 2015 Michael K. Squires

afplay's People

Contributors

sqmk avatar

Watchers

Ibrahim Mjawara SISSOKO avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.