nativescript-forgm-sound
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

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 );

Package Sidebar

Install

npm i nativescript-forgm-sound

Weekly Downloads

0

Version

1.1.3

License

Apache-2.0

Unpacked Size

45.3 kB

Total Files

22

Last publish

Collaborators

  • forgm