nativescript-forgm-sound
Fork of original nativescript-sound plugin with implemented 13.2 iOS fixed and transfer to use typescript with nativescript-plugin-seed
npm i --save nativescript-forgm-sound
- Version: 1.1.3
- GitHub: https://github.com/forgm/nativescript-sound
- NPM: https://www.npmjs.com/package/nativescript-forgm-sound
- Downloads:
- Last Day: 0
- Last Week: 0
- Last Month: 0
NativeScript Sound
Play a sound in your NativeScript app.
John Bristowe has initially programmed this project. The starting point was Grey Laureckis (PR #9) fork that includes code from PR #8. Mathew Thompson's iOS 13.2 fix is also implemented. Nativescript-plugin-seed was used to move it from JS to TypeScript. The demo tested on iOS 13.3 Simulator and Android API 28 virtual device
Installation
npm i nativescript-forgm-sound --save
Usage
To use this plugin you must first import it:
import { Sound } from 'nativescript-forgm-sound';
init and play
Preload sound before playing it because there is a delay during creation due to the audio being processed.
const beep: Sound = new Sound('~/sounds/beep.wav');
// play the sound (i.e. tap event handler)
beep.play();
pause
beep.pause();
resume
beep.resume();
stop
beep.stop();
release
After release(), if you play(), the app should crash.
beep.release();
setVolume
Sets volume, the volume should be limited from 0.0 to 1.0. fadeDuration in milliseconds only for iOS.
beep.setVolume(volume: number, fadeDuration?: number );