-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.d.ts
207 lines (166 loc) · 4.01 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
import { Observable } from 'tns-core-modules/data/observable';
export interface AudioPlayerOptions {
/**
* The audio file to play.
*/
audioFile: string;
/**
* Set true to loop audio playback.
*/
loop: boolean;
/**
* Prevent autoplay if desired as player autoplays be default
*/
autoPlay?: boolean;
/**
* Set true to enable audio metering.
*/
metering?: boolean;
/**
* Callback to execute when playback has completed.
* @returns {Object} An object containing the native values for the callback.
*/
completeCallback?: Function;
/**
* Callback to execute when playback has an error.
* @returns {Object} An object containing the native values for the error callback.
*/
errorCallback?: Function;
/**
* Callback to execute when info is emitted from the player.
* @returns {Object} An object containing the native values for the info callback.
*/
infoCallback?: Function;
}
export interface TNSPlayerI {
readonly ios?: any;
readonly android?: any;
/**
* Set to true to enable console log output for debugging.
*/
debug: boolean;
/**
* Volume getter/setter
*/
volume: any;
/**
* Duration getter
*/
duration: number;
initFromFile(options: AudioPlayerOptions): Promise<any>;
/**
* Starts playing audio file from local app files.
*/
playFromFile(options: AudioPlayerOptions): Promise<any>;
initFromUrl(options: AudioPlayerOptions): Promise<any>;
/**
* Starts playing audio file from url
*/
playFromUrl(options: AudioPlayerOptions): Promise<any>;
/**
* Play audio file.
*/
play(): Promise<boolean>;
/**
* Pauses playing audio file.
*/
pause(): Promise<boolean>;
/**
* Resume audio player.
*/
resume(): void;
/**
* Seeks to specific time.
*/
seekTo(time: number): Promise<any>;
/**
* Releases resources from the audio player.
*/
dispose(): Promise<boolean>;
/**
* Check if the audio is actively playing.
*/
isAudioPlaying(): boolean;
/**
* Get the duration of the audio file playing.
*/
getAudioTrackDuration(): Promise<string>;
/**
* Sets the player playback speed rate. On Android this works on API 23+.
* @param speed [number] - The speed of the playback.
*/
changePlayerSpeed(speed: number): void;
}
export declare class TNSPlayer {
static ObjCProtocols: any[];
readonly ios: any;
readonly android: any;
readonly events: Observable;
/**
* Set to true to enable console log output for debugging.
*/
debug: boolean;
/**
* Volume getter/setter
*/
volume: any;
/**
* duration
*/
duration: number;
/**
* current time
*/
readonly currentTime: number;
initFromFile(options: AudioPlayerOptions): Promise<any>;
/**
* Starts playing audio file from local app files.
*/
playFromFile(options: AudioPlayerOptions): Promise<any>;
initFromUrl(options: AudioPlayerOptions): Promise<any>;
/**
* Starts playing audio file from url
*/
playFromUrl(options: AudioPlayerOptions): Promise<any>;
/**
* Play audio file.
*/
play(): Promise<boolean>;
/**
* Pauses playing audio file.
*/
pause(): Promise<boolean>;
/**
* Resume audio player.
*/
resume(): void;
/**
* Seeks to specific time.
*/
seekTo(time: number): Promise<any>;
/**
* Releases resources from the audio player.
*/
dispose(): Promise<boolean>;
/**
* Check if the audio is actively playing.
*/
isAudioPlaying(): boolean;
/**
* Get the duration of the audio file playing.
*/
getAudioTrackDuration(): Promise<string>;
/**
* Android Only
* Will set the playback speed for Android 23+, this is not available on lower Android APIs.
* @param speed [number] - The speed of the playback.
*/
changePlayerSpeed(speed: number): void;
audioPlayerDidFinishPlayingSuccessfully(player?: any, flag?: boolean): void;
}
export interface IAudioPlayerEvents {
seek: 'seek';
paused: 'paused';
started: 'started';
}
export const AudioPlayerEvents: IAudioPlayerEvents;