audio-channel-queue 1.6.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.js +53 -34
- package/dist/errors.d.ts +137 -0
- package/dist/errors.js +461 -0
- package/dist/index.d.ts +10 -25
- package/dist/index.js +36 -32
- package/dist/info.d.ts +2 -1
- package/dist/info.js +8 -1
- package/dist/pause.d.ts +71 -0
- package/dist/pause.js +205 -2
- package/dist/types.d.ts +93 -20
- package/dist/types.js +20 -0
- package/dist/volume.d.ts +28 -3
- package/dist/volume.js +52 -9
- package/package.json +1 -1
- package/src/core.ts +55 -35
- package/src/errors.ts +480 -0
- package/src/index.ts +87 -83
- package/src/info.ts +8 -1
- package/src/pause.ts +411 -189
- package/src/types.ts +99 -18
- package/src/volume.ts +375 -327
package/src/types.ts
CHANGED
|
@@ -29,7 +29,7 @@ export interface VolumeConfig {
|
|
|
29
29
|
/** Duration in milliseconds for volume restore transition (defaults to 500ms) */
|
|
30
30
|
restoreTransitionDuration?: number;
|
|
31
31
|
/** Easing function for volume transitions (defaults to 'ease-out') */
|
|
32
|
-
transitionEasing?:
|
|
32
|
+
transitionEasing?: EasingType;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
@@ -175,25 +175,106 @@ export type AudioPauseCallback = (channelNumber: number, audioInfo: AudioInfo) =
|
|
|
175
175
|
export type AudioResumeCallback = (channelNumber: number, audioInfo: AudioInfo) => void;
|
|
176
176
|
|
|
177
177
|
/**
|
|
178
|
-
*
|
|
178
|
+
* Information about an audio error that occurred
|
|
179
179
|
*/
|
|
180
|
-
export
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
180
|
+
export interface AudioErrorInfo {
|
|
181
|
+
channelNumber: number;
|
|
182
|
+
src: string;
|
|
183
|
+
fileName: string;
|
|
184
|
+
error: Error;
|
|
185
|
+
errorType: 'network' | 'decode' | 'unsupported' | 'permission' | 'abort' | 'timeout' | 'unknown';
|
|
186
|
+
timestamp: number;
|
|
187
|
+
retryAttempt?: number;
|
|
188
|
+
remainingInQueue: number;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Configuration for automatic retry behavior when audio fails to load or play
|
|
193
|
+
*/
|
|
194
|
+
export interface RetryConfig {
|
|
195
|
+
enabled: boolean;
|
|
196
|
+
maxRetries: number;
|
|
197
|
+
baseDelay: number;
|
|
198
|
+
exponentialBackoff: boolean;
|
|
199
|
+
timeoutMs: number;
|
|
200
|
+
fallbackUrls?: string[];
|
|
201
|
+
skipOnFailure: boolean;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Configuration options for error recovery mechanisms
|
|
206
|
+
*/
|
|
207
|
+
export interface ErrorRecoveryOptions {
|
|
208
|
+
autoRetry: boolean;
|
|
209
|
+
showUserFeedback: boolean;
|
|
210
|
+
logErrorsToAnalytics: boolean;
|
|
211
|
+
preserveQueueOnError: boolean;
|
|
212
|
+
fallbackToNextTrack: boolean;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Callback function type for audio error events
|
|
217
|
+
*/
|
|
218
|
+
export type AudioErrorCallback = (errorInfo: AudioErrorInfo) => void;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Extended audio queue channel with error handling capabilities
|
|
222
|
+
*/
|
|
223
|
+
export interface ExtendedAudioQueueChannel {
|
|
224
|
+
audioCompleteCallbacks: Set<AudioCompleteCallback>;
|
|
225
|
+
audioErrorCallbacks: Set<AudioErrorCallback>;
|
|
226
|
+
audioPauseCallbacks: Set<AudioPauseCallback>;
|
|
227
|
+
audioResumeCallbacks: Set<AudioResumeCallback>;
|
|
228
|
+
audioStartCallbacks: Set<AudioStartCallback>;
|
|
229
|
+
fadeState?: ChannelFadeState;
|
|
190
230
|
isPaused?: boolean;
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
/** Current volume level for this channel (0-1) */
|
|
231
|
+
progressCallbacks: Map<HTMLAudioElement | null, Set<ProgressCallback>>;
|
|
232
|
+
queue: HTMLAudioElement[];
|
|
233
|
+
queueChangeCallbacks: Set<QueueChangeCallback>;
|
|
234
|
+
retryConfig?: RetryConfig;
|
|
196
235
|
volume?: number;
|
|
197
|
-
/** Volume ducking configuration for this channel */
|
|
198
236
|
volumeConfig?: VolumeConfig;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Easing function types for volume transitions
|
|
241
|
+
*/
|
|
242
|
+
export enum EasingType {
|
|
243
|
+
Linear = 'linear',
|
|
244
|
+
EaseIn = 'ease-in',
|
|
245
|
+
EaseOut = 'ease-out',
|
|
246
|
+
EaseInOut = 'ease-in-out'
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Fade type for pause/resume operations with integrated volume transitions
|
|
251
|
+
*/
|
|
252
|
+
export enum FadeType {
|
|
253
|
+
Linear = 'linear',
|
|
254
|
+
Gentle = 'gentle',
|
|
255
|
+
Dramatic = 'dramatic'
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Configuration for fade transitions
|
|
260
|
+
*/
|
|
261
|
+
export interface FadeConfig {
|
|
262
|
+
/** Duration in milliseconds for the fade transition */
|
|
263
|
+
duration: number;
|
|
264
|
+
/** Easing curve to use when pausing (fading out) */
|
|
265
|
+
pauseCurve: EasingType;
|
|
266
|
+
/** Easing curve to use when resuming (fading in) */
|
|
267
|
+
resumeCurve: EasingType;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Internal fade state tracking for pause/resume with fade functionality
|
|
272
|
+
*/
|
|
273
|
+
export interface ChannelFadeState {
|
|
274
|
+
/** The original volume level before fading began */
|
|
275
|
+
originalVolume: number;
|
|
276
|
+
/** The type of fade being used */
|
|
277
|
+
fadeType: FadeType;
|
|
278
|
+
/** Whether the channel is currently paused due to fade */
|
|
279
|
+
isPaused: boolean;
|
|
199
280
|
}
|