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