-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added startAudioListening addEventListener functions to library
- Loading branch information
1 parent
58eed7f
commit 5a10a0e
Showing
3 changed files
with
13,455 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
import { NativeModules, Platform } from 'react-native'; | ||
import { NativeModules } from 'react-native'; | ||
|
||
const LINKING_ERROR = | ||
`The package 'react-native-live-audio-visualizer' doesn't seem to be linked. Make sure: \n\n` + | ||
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) + | ||
'- You rebuilt the app after installing the package\n' + | ||
'- You are not using Expo Go\n'; | ||
const LiveAudioVisualizer = NativeModules.LiveAudioVisualizer; | ||
|
||
const LiveAudioVisualizer = NativeModules.LiveAudioVisualizer | ||
? NativeModules.LiveAudioVisualizer | ||
: new Proxy( | ||
{}, | ||
{ | ||
get() { | ||
throw new Error(LINKING_ERROR); | ||
}, | ||
} | ||
); | ||
export function startAudioListening(): Promise<void> { | ||
return LiveAudioVisualizer.startAudioListening(); | ||
} | ||
|
||
export function stopAudioListening(): Promise<void> { | ||
return LiveAudioVisualizer.stopAudioListening(); | ||
} | ||
|
||
export function setSensitivity(sensitivity: number): Promise<void> { | ||
return LiveAudioVisualizer.setSensitivity(sensitivity); | ||
} | ||
|
||
export function multiply(a: number, b: number): Promise<number> { | ||
return LiveAudioVisualizer.multiply(a, b); | ||
export function addEventListener(callback: (data: any) => void): void { | ||
LiveAudioVisualizer.addListener('audioStarted', callback); | ||
LiveAudioVisualizer.addListener('VisualizationChanged', callback); | ||
} |
Oops, something went wrong.