1 | import { IonicNativePlugin } from '@ionic-native/core';
|
2 | /**
|
3 | * @name Native Audio
|
4 | * @description Native Audio Playback
|
5 | * @usage
|
6 | * ```typescript
|
7 | * import { NativeAudio } from '@ionic-native/native-audio/ngx';
|
8 | *
|
9 | * constructor(private nativeAudio: NativeAudio) { }
|
10 | *
|
11 | * ...
|
12 | *
|
13 | * this.nativeAudio.preloadSimple('uniqueId1', 'path/to/file.mp3').then(onSuccess, onError);
|
14 | * this.nativeAudio.preloadComplex('uniqueId2', 'path/to/file2.mp3', 1, 1, 0).then(onSuccess, onError);
|
15 | *
|
16 | * this.nativeAudio.play('uniqueId1').then(onSuccess, onError);
|
17 | *
|
18 | * // can optionally pass a callback to be called when the file is done playing
|
19 | * this.nativeAudio.play('uniqueId1', () => console.log('uniqueId1 is done playing'));
|
20 | *
|
21 | * this.nativeAudio.loop('uniqueId2').then(onSuccess, onError);
|
22 | *
|
23 | * this.nativeAudio.setVolumeForComplexAsset('uniqueId2', 0.6).then(onSuccess,onError);
|
24 | *
|
25 | * this.nativeAudio.stop('uniqueId1').then(onSuccess,onError);
|
26 | *
|
27 | * this.nativeAudio.unload('uniqueId1').then(onSuccess,onError);
|
28 | *
|
29 | * ```
|
30 | */
|
31 | export declare class NativeAudio extends IonicNativePlugin {
|
32 | /**
|
33 | * Loads an audio file into memory. Optimized for short clips / single shots (up to five seconds). Cannot be stopped / looped.
|
34 | * @param id {string} unique ID for the audio file
|
35 | * @param assetPath {string} the relative path or absolute URL (inluding http://) to the audio asset.
|
36 | * @returns {Promise<any>}
|
37 | */
|
38 | preloadSimple(id: string, assetPath: string): Promise<any>;
|
39 | /**
|
40 | * Loads an audio file into memory. Optimized for background music / ambient sound. Uses highlevel native APIs with a larger footprint. (iOS: AVAudioPlayer). Can be stopped / looped and used with multiple voices. Can be faded in and out using the delay parameter.
|
41 | * @param id {string} unique ID for the audio file
|
42 | * @param assetPath {string} the relative path or absolute URL (inluding http://) to the audio asset.
|
43 | * @param volume {number} the volume of the preloaded sound (0.1 to 1.0)
|
44 | * @param voices {number} the number of multichannel voices available
|
45 | * @param delay {number}
|
46 | * @returns {Promise<any>}
|
47 | */
|
48 | preloadComplex(id: string, assetPath: string, volume: number, voices: number, delay: number): Promise<any>;
|
49 | /**
|
50 | * Plays an audio asset
|
51 | * @param id {string} unique ID for the audio file
|
52 | * @param completeCallback {Function} optional. Callback to be invoked when audio is done playing
|
53 | * @returns {Promise<any>}
|
54 | */
|
55 | play(id: string, completeCallback?: Function): Promise<any>;
|
56 | /**
|
57 | * Stops playing an audio
|
58 | * @param id {string} unique ID for the audio file
|
59 | * @returns {Promise<any>}
|
60 | */
|
61 | stop(id: string): Promise<any>;
|
62 | /**
|
63 | * Loops an audio asset infinitely, this only works for complex assets
|
64 | * @param id {string} unique ID for the audio file
|
65 | * @return {Promise<any>}
|
66 | */
|
67 | loop(id: string): Promise<any>;
|
68 | /**
|
69 | * Unloads an audio file from memory
|
70 | * @param id {string} unique ID for the audio file
|
71 | * @returns {Promise<any>}
|
72 | */
|
73 | unload(id: string): Promise<any>;
|
74 | /**
|
75 | * Changes the volume for preloaded complex assets.
|
76 | * @param id {string} unique ID for the audio file
|
77 | * @param volume {number} the volume of the audio asset (0.1 to 1.0)
|
78 | * @returns {Promise<any>}
|
79 | */
|
80 | setVolumeForComplexAsset(id: string, volume: number): Promise<any>;
|
81 | }
|