capacitor-sound-effect
Advanced tools
Comparing version 2.0.1 to 3.0.0
{ | ||
"name": "capacitor-sound-effect", | ||
"version": "2.0.1", | ||
"version": "3.0.0", | ||
"description": "Native sound effects", | ||
@@ -47,6 +47,6 @@ "main": "dist/plugin.cjs.js", | ||
"devDependencies": { | ||
"@capacitor/android": "^3.0.0", | ||
"@capacitor/core": "^3.0.0", | ||
"@capacitor/android": "^4.0.0", | ||
"@capacitor/core": "^4.0.0", | ||
"@capacitor/docgen": "^0.0.10", | ||
"@capacitor/ios": "^3.0.0", | ||
"@capacitor/ios": "^4.0.0", | ||
"@ionic/eslint-config": "^0.3.0", | ||
@@ -64,3 +64,3 @@ "@ionic/prettier-config": "^1.0.1", | ||
"peerDependencies": { | ||
"@capacitor/core": "^3.0.0" | ||
"@capacitor/core": "^4.0.0" | ||
}, | ||
@@ -67,0 +67,0 @@ "prettier": "@ionic/prettier-config", |
# capacitor-sound-effect | ||
Native sound effects | ||
This plugin provides the ability to natively play sound effects in Capacitor based projects. | ||
## Install | ||
### General | ||
```bash | ||
@@ -12,2 +13,8 @@ npm install capacitor-sound-effect | ||
### Ionic | ||
```bash | ||
npm install capacitor-sound-effect | ||
ionic cap sync | ||
``` | ||
## API | ||
@@ -55,1 +62,32 @@ | ||
</docgen-api> | ||
## Usage Example | ||
This example is based on an Ionic (Vue) project, but is generally applicable to other scenarios | ||
#### Import the plugin | ||
```javascript | ||
import { SoundEffect } from 'capacitor-sound-effect'; | ||
``` | ||
#### Load the sounds | ||
In Ionic, the path is relative to your 'public' directory. So for a file located in /public/assets/sounds/, the below is applicable: | ||
```javascript | ||
loadSounds() { | ||
SoundEffect.loadSound({id:'message', path:'assets/sounds/message.mp3'}); | ||
SoundEffect.loadSound({id:'status', path:'assets/sounds/status.mp3'}); | ||
} | ||
``` | ||
You must pass an object, as illustrated above, to the loadSound() method. The 'id' must be unique as it is used to reference the sound when you come to playing. | ||
#### Play a sound | ||
When playing a sound, you must reference the 'id' you provided during loadSound(). | ||
```javascript | ||
SoundEffect.play({id:'message'}); | ||
``` |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
22122
92
0