npm package: @kefah/nativescript-sound
Description: Add a plugin description
Author: KefahB
Latest version: 1.0.1

# @kefah/nativescript-sound

## This is a plugin to play games short sound

> Limitations
> Android app can play only sound under 1MB (5.6 seconds)
> Do not play a large audio with this plugin, it is not made for


```javascript
npm install @kefah/nativescript-sound
```

## Usage

### Do not forged Webpack!
```ts
  const config = webpack.resolveConfig();
  const customCopyInstance = new CopyWebpackPlugin({
    patterns: [
        ...
      { from: 'sounds/*.mp3'}, // put here the path to the s-audio file
    ],
  });

  config.plugins.push(customCopyInstance);
  return config;
```

Use it :-)

```ts
    import { NativescriptSound, SoundPathInterface } from '@kefah/nativescript-sound';

    /**
     * Do not forged to configure webpack for your audio file
     * */

    const appPath: string = knownFolders.currentApp().path;
    const soundsPath = path.join(appPath, "sounds");
    this.sounds = {
        "success": {   
            path: path.join(soundsPath, "card_palyed_1.mp3")
        },
        "msg": {   
            path: path.join(soundsPath, "card_played_2.mp3")
        },
        "success_1": {
            path: path.join(soundsPath, "card_played.mp3")
        },
        "shuffle": {   
            path: path.join(soundsPath, "card_shuffle.mp3")
        },
        "wrong": {   
            path: path.join(soundsPath, "card_swipe.mp3")
        }
    };

    this.player = new NativescriptSound(10)

    // Prepare all the audio to be played later
    this.player.prepare({
        paths: this.sounds,
        onLoadCompleted: (player, sampleId, status) => {
            console.log(`${sampleId} with status ${status}`)
        }
    });

    // ... 
    // Later on the game, play the sound
    this.player.play({
        name: "success"
    });
```

# API
<table>
    <thead>
        <tr>
            <td>Name</td>
            <td>IOS</td>
            <td>ANDROID</td>
            <td>Type</td>
            <td>Description</td>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>prepare</td>
            <td>X</td>
            <td>X</td>
            <td>paths: SoundsOptions</td>
            <td>Prepare a list of audios to be played later on the game</td>
        </tr>
        <tr>
            <td>play</td>
            <td>X</td>
            <td>X</td>
            <td>playOptions: PlayOptions</td>
            <td>Play a specific audio</td>
        </tr>
        <tr>
            <td>stop</td>
            <td>X</td>
            <td>X</td>
            <td>soundName: string</td>
            <td>Stop the audio with the sound name</td>
        </tr>
        <tr>
            <td>pause</td>
            <td>X</td>
            <td>X</td>
            <td>soundName: string</td>
            <td>Pause the audio</td>
        </tr>
        <tr>
            <td>resume</td>
            <td></td>
            <td>X</td>
            <td>soundName: string</td>
            <td>resume the audio</td>
        </tr>
        <tr>
            <td>setVolume</td>
            <td>X</td>
            <td>X</td>
            <td>soundName: string</td>
            <td>set the volume of the audio</td>
        </tr>
        <tr>
            <td>setRate</td>
            <td>X</td>
            <td>X</td>
            <td>soundName: string</td>
            <td>set the speed of the audio</td>
        </tr>
        <tr>
            <td>unload</td>
            <td></td>
            <td>X</td>
            <td>soundName: string</td>
            <td>unload audio, you need new instance after calling this to reload the audio</td>
        </tr>
        <tr>
            <td>releaseAll</td>
            <td></td>
            <td>X</td>
            <td></td>
            <td>unload all audios, you need new instance after calling this to reload the audio</td>
        </tr>
    </tbody>
</table>

## License

Apache License Version 2.0