Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

sound-play-terminus

nomadhoc6MIT1.0.0

A sound player for NodeJS.

sound, audio, play, player, music, electron, desktop, node, react native, window, mac, sound play, audio play, music play, sound player, audio player, music player, node audio, audio node

readme

sound-play

Dead simple sound player for Node -- because it should be simple.

const sound = require('sound-play')
sound.play('file.mp3')
  • Support .wav, .mp3 and other extensions.

  • Work on Windows and MacOS

Install

npm install sound-play
yarn add sound-play

Examples

Relative path

sound.play('file.mp3')

or

const path = require('path')
const filePath = path.join(__dirname, 'file.mp3')
sound.play(filePath)

Absolute path

sound.play('C:\\file.mp3')

Promise

sound.play('C:\\file.mp3').then(response => console.log('done'))

Async/await

try {
  await sound.play('C:\\file.mp3')
  console.log('done')
} catch (error) {
  console.error(error)
}

License

MIT