audioq 2.0.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/pause.js ADDED
@@ -0,0 +1,467 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Pause and resume management functions for the audioq package
4
+ */
5
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
+ return new (P || (P = Promise))(function (resolve, reject) {
8
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
12
+ });
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.togglePauseAllChannels = exports.getAllChannelsPauseState = exports.isChannelPaused = exports.resumeAllChannels = exports.pauseAllChannels = exports.togglePauseChannel = exports.resumeChannel = exports.pauseChannel = exports.togglePauseAllWithFade = exports.resumeAllWithFade = exports.pauseAllWithFade = exports.togglePauseWithFade = exports.resumeWithFade = exports.pauseWithFade = void 0;
16
+ const types_1 = require("./types");
17
+ const info_1 = require("./info");
18
+ const utils_1 = require("./utils");
19
+ const events_1 = require("./events");
20
+ const volume_1 = require("./volume");
21
+ const web_audio_1 = require("./web-audio");
22
+ /**
23
+ * Gets the current volume for a channel, accounting for synchronous state
24
+ * @param channelNumber - The channel number
25
+ * @returns Current volume level (0-1)
26
+ */
27
+ const getChannelVolumeSync = (channelNumber) => {
28
+ var _a;
29
+ const channel = info_1.audioChannels[channelNumber];
30
+ return (_a = channel === null || channel === void 0 ? void 0 : channel.volume) !== null && _a !== void 0 ? _a : 1.0;
31
+ };
32
+ /**
33
+ * Sets the channel volume synchronously in internal state
34
+ * @param channelNumber - The channel number
35
+ * @param volume - Volume level (0-1)
36
+ */
37
+ const setChannelVolumeSync = (channelNumber, volume) => {
38
+ const channel = info_1.audioChannels[channelNumber];
39
+ if (channel) {
40
+ channel.volume = volume;
41
+ if (channel.queue.length > 0) {
42
+ const audio = channel.queue[0];
43
+ if (channel.webAudioNodes) {
44
+ const nodes = channel.webAudioNodes.get(audio);
45
+ if (nodes) {
46
+ // Update the gain node when Web Audio is active
47
+ (0, web_audio_1.setWebAudioVolume)(nodes.gainNode, volume);
48
+ }
49
+ }
50
+ audio.volume = volume;
51
+ }
52
+ }
53
+ };
54
+ /**
55
+ * Pauses the currently playing audio in a specific channel with smooth volume fade
56
+ * @param fadeType - Type of fade transition to apply
57
+ * @param channelNumber - The channel number to pause (defaults to 0)
58
+ * @param duration - Optional custom fade duration in milliseconds (uses fadeType default if not provided)
59
+ * @returns Promise that resolves when the pause and fade are complete
60
+ * @example
61
+ * ```typescript
62
+ * await pauseWithFade(FadeType.Gentle, 0); // Pause with gentle fade out over 800ms
63
+ * await pauseWithFade(FadeType.Dramatic, 1, 1500); // Pause with dramatic fade out over 1.5s
64
+ * await pauseWithFade(FadeType.Linear, 2, 500); // Linear pause with custom 500ms fade
65
+ * ```
66
+ */
67
+ const pauseWithFade = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (fadeType = types_1.FadeType.Gentle, channelNumber = 0, duration) {
68
+ var _a, _b, _c;
69
+ const channel = info_1.audioChannels[channelNumber];
70
+ if (!channel || channel.queue.length === 0) {
71
+ return;
72
+ }
73
+ const currentAudio = channel.queue[0];
74
+ // Don't pause if already paused or ended
75
+ if (currentAudio.paused || currentAudio.ended) {
76
+ return;
77
+ }
78
+ const config = (0, volume_1.getFadeConfig)(fadeType);
79
+ const effectiveDuration = duration !== null && duration !== void 0 ? duration : config.duration;
80
+ // Race condition fix: Use existing fadeState originalVolume if already transitioning,
81
+ // otherwise capture current volume
82
+ let originalVolume;
83
+ if ((_a = channel.fadeState) === null || _a === void 0 ? void 0 : _a.isTransitioning) {
84
+ // We're already in any kind of transition (pause or resume), preserve original volume
85
+ originalVolume = channel.fadeState.originalVolume;
86
+ }
87
+ else {
88
+ // First fade or no transition in progress, capture current volume
89
+ // But ensure we don't capture a volume of 0 during a transition
90
+ const currentVolume = getChannelVolumeSync(channelNumber);
91
+ originalVolume = currentVolume > 0 ? currentVolume : ((_c = (_b = channel.fadeState) === null || _b === void 0 ? void 0 : _b.originalVolume) !== null && _c !== void 0 ? _c : 1.0);
92
+ }
93
+ // Store fade state for resumeWithFade to use (including custom duration)
94
+ channel.fadeState = {
95
+ customDuration: duration,
96
+ fadeType,
97
+ isPaused: true,
98
+ isTransitioning: true,
99
+ originalVolume
100
+ };
101
+ if (effectiveDuration === 0) {
102
+ // Instant pause
103
+ yield (0, exports.pauseChannel)(channelNumber);
104
+ // Reset volume to original for resume (synchronously to avoid state issues)
105
+ setChannelVolumeSync(channelNumber, originalVolume);
106
+ // Mark transition as complete for instant pause
107
+ if (channel.fadeState) {
108
+ channel.fadeState.isTransitioning = false;
109
+ }
110
+ return;
111
+ }
112
+ // Fade to 0 with pause curve, then pause
113
+ yield (0, volume_1.transitionVolume)(channelNumber, 0, effectiveDuration, config.pauseCurve);
114
+ // Pause the audio
115
+ yield (0, exports.pauseChannel)(channelNumber);
116
+ // Restore channel.volume for resume, but DON'T restore gain node to prevent blip
117
+ // The gain node will be restored during the resume fade
118
+ channel.volume = originalVolume;
119
+ // Mark transition as complete
120
+ if (channel.fadeState) {
121
+ channel.fadeState.isTransitioning = false;
122
+ }
123
+ });
124
+ exports.pauseWithFade = pauseWithFade;
125
+ /**
126
+ * Resumes the currently paused audio in a specific channel with smooth volume fade
127
+ * Uses the complementary fade curve automatically based on the pause fade type, or allows override
128
+ * @param fadeType - Optional fade type to override the stored fade type from pause
129
+ * @param channelNumber - The channel number to resume (defaults to 0)
130
+ * @param duration - Optional custom fade duration in milliseconds (uses stored or fadeType default if not provided)
131
+ * @returns Promise that resolves when the resume and fade are complete
132
+ * @example
133
+ * ```typescript
134
+ * await resumeWithFade(); // Resume with automatically paired fade curve from pause
135
+ * await resumeWithFade(FadeType.Dramatic, 0); // Override with dramatic fade
136
+ * await resumeWithFade(FadeType.Linear, 0, 1000); // Override with linear fade over 1 second
137
+ * ```
138
+ */
139
+ const resumeWithFade = (fadeType_1, ...args_1) => __awaiter(void 0, [fadeType_1, ...args_1], void 0, function* (fadeType, channelNumber = 0, duration) {
140
+ const channel = info_1.audioChannels[channelNumber];
141
+ if (!channel || channel.queue.length === 0) {
142
+ return;
143
+ }
144
+ const audio = channel.queue[0];
145
+ const fadeState = channel.fadeState;
146
+ if (!(fadeState === null || fadeState === void 0 ? void 0 : fadeState.isPaused)) {
147
+ // Fall back to regular resume if no fade state
148
+ yield (0, exports.resumeChannel)(channelNumber);
149
+ return;
150
+ }
151
+ // Use provided fadeType or fall back to stored fadeType from pause
152
+ const effectiveFadeType = fadeType !== null && fadeType !== void 0 ? fadeType : fadeState.fadeType;
153
+ const config = (0, volume_1.getFadeConfig)(effectiveFadeType);
154
+ // Determine effective duration: custom parameter > stored custom > fadeType default
155
+ let effectiveDuration;
156
+ if (duration !== undefined) {
157
+ effectiveDuration = duration;
158
+ }
159
+ else if (fadeState.customDuration !== undefined) {
160
+ effectiveDuration = fadeState.customDuration;
161
+ }
162
+ else {
163
+ effectiveDuration = config.duration;
164
+ }
165
+ if (effectiveDuration === 0) {
166
+ // Instant resume
167
+ const targetVolume = fadeState.originalVolume > 0 ? fadeState.originalVolume : 1.0;
168
+ setChannelVolumeSync(channelNumber, targetVolume);
169
+ yield (0, exports.resumeChannel)(channelNumber);
170
+ fadeState.isPaused = false;
171
+ fadeState.isTransitioning = false;
172
+ return;
173
+ }
174
+ // Race condition fix: Ensure we have a valid original volume to restore to
175
+ const targetVolume = fadeState.originalVolume > 0 ? fadeState.originalVolume : 1.0;
176
+ // Mark as transitioning to prevent volume capture during rapid toggles
177
+ fadeState.isTransitioning = true;
178
+ // Ensure gain node is at 0 before resuming (should already be from pause)
179
+ // Don't touch audio.volume when Web Audio is active - iOS may reset it
180
+ // Don't touch channel.volume - it should stay at originalVolume
181
+ if (channel.webAudioNodes) {
182
+ const nodes = channel.webAudioNodes.get(audio);
183
+ if (nodes) {
184
+ (0, web_audio_1.setWebAudioVolume)(nodes.gainNode, 0);
185
+ }
186
+ }
187
+ else {
188
+ // Fallback for non-Web Audio: set audio.volume directly
189
+ audio.volume = 0;
190
+ }
191
+ yield (0, exports.resumeChannel)(channelNumber);
192
+ // Use the stored original volume, not current volume, to prevent race conditions
193
+ yield (0, volume_1.transitionVolume)(channelNumber, targetVolume, effectiveDuration, config.resumeCurve);
194
+ fadeState.isPaused = false;
195
+ fadeState.isTransitioning = false;
196
+ });
197
+ exports.resumeWithFade = resumeWithFade;
198
+ /**
199
+ * Toggles pause/resume state for a specific channel with integrated fade
200
+ * @param fadeType - Type of fade transition to apply when pausing
201
+ * @param channelNumber - The channel number to toggle (defaults to 0)
202
+ * @param duration - Optional custom fade duration in milliseconds (uses fadeType default if not provided)
203
+ * @returns Promise that resolves when the toggle and fade are complete
204
+ * @example
205
+ * ```typescript
206
+ * await togglePauseWithFade(FadeType.Gentle, 0); // Toggle with gentle fade
207
+ * await togglePauseWithFade(FadeType.Dramatic, 0, 500); // Toggle with custom 500ms fade
208
+ * ```
209
+ */
210
+ const togglePauseWithFade = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (fadeType = types_1.FadeType.Gentle, channelNumber = 0, duration) {
211
+ const channel = info_1.audioChannels[channelNumber];
212
+ if (!channel || channel.queue.length === 0)
213
+ return;
214
+ const currentAudio = channel.queue[0];
215
+ if (currentAudio.paused) {
216
+ yield (0, exports.resumeWithFade)(undefined, channelNumber, duration);
217
+ }
218
+ else {
219
+ yield (0, exports.pauseWithFade)(fadeType, channelNumber, duration);
220
+ }
221
+ });
222
+ exports.togglePauseWithFade = togglePauseWithFade;
223
+ /**
224
+ * Pauses all currently playing audio across all channels with smooth volume fade
225
+ * @param fadeType - Type of fade transition to apply to all channels
226
+ * @param duration - Optional custom fade duration in milliseconds (uses fadeType default if not provided)
227
+ * @returns Promise that resolves when all channels are paused and faded
228
+ * @example
229
+ * ```typescript
230
+ * await pauseAllWithFade(FadeType.Dramatic); // Pause everything with dramatic fade
231
+ * await pauseAllWithFade(FadeType.Gentle, 1200); // Pause all channels with custom 1.2s fade
232
+ * ```
233
+ */
234
+ const pauseAllWithFade = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (fadeType = types_1.FadeType.Gentle, duration) {
235
+ const pausePromises = [];
236
+ info_1.audioChannels.forEach((_channel, index) => {
237
+ pausePromises.push((0, exports.pauseWithFade)(fadeType, index, duration));
238
+ });
239
+ yield Promise.all(pausePromises);
240
+ });
241
+ exports.pauseAllWithFade = pauseAllWithFade;
242
+ /**
243
+ * Resumes all currently paused audio across all channels with smooth volume fade
244
+ * Uses automatically paired fade curves based on each channel's pause fade type, or allows override
245
+ * @param fadeType - Optional fade type to override stored fade types for all channels
246
+ * @param duration - Optional custom fade duration in milliseconds (uses stored or fadeType default if not provided)
247
+ * @returns Promise that resolves when all channels are resumed and faded
248
+ * @example
249
+ * ```typescript
250
+ * await resumeAllWithFade(); // Resume everything with paired fade curves
251
+ * await resumeAllWithFade(FadeType.Gentle, 800); // Override all channels with gentle fade over 800ms
252
+ * await resumeAllWithFade(undefined, 600); // Use stored fade types with custom 600ms duration
253
+ * ```
254
+ */
255
+ const resumeAllWithFade = (fadeType, duration) => __awaiter(void 0, void 0, void 0, function* () {
256
+ const resumePromises = [];
257
+ info_1.audioChannels.forEach((_channel, index) => {
258
+ resumePromises.push((0, exports.resumeWithFade)(fadeType, index, duration));
259
+ });
260
+ yield Promise.all(resumePromises);
261
+ });
262
+ exports.resumeAllWithFade = resumeAllWithFade;
263
+ /**
264
+ * Toggles pause/resume state for all channels with integrated fade
265
+ * If any channels are playing, all will be paused with fade
266
+ * If all channels are paused, all will be resumed with fade
267
+ * @param fadeType - Type of fade transition to apply when pausing
268
+ * @param duration - Optional custom fade duration in milliseconds (uses fadeType default if not provided)
269
+ * @returns Promise that resolves when all toggles and fades are complete
270
+ * @example
271
+ * ```typescript
272
+ * await togglePauseAllWithFade(FadeType.Gentle); // Global toggle with gentle fade
273
+ * await togglePauseAllWithFade(FadeType.Dramatic, 600); // Global toggle with custom 600ms fade
274
+ * ```
275
+ */
276
+ const togglePauseAllWithFade = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (fadeType = types_1.FadeType.Gentle, duration) {
277
+ let hasPlayingChannel = false;
278
+ // Check if any channel is currently playing
279
+ for (let i = 0; i < info_1.audioChannels.length; i++) {
280
+ const channel = info_1.audioChannels[i];
281
+ if (channel && channel.queue.length > 0) {
282
+ const currentAudio = channel.queue[0];
283
+ if (!currentAudio.paused && !currentAudio.ended) {
284
+ hasPlayingChannel = true;
285
+ break;
286
+ }
287
+ }
288
+ }
289
+ // If any channel is playing, pause all with fade
290
+ // If no channels are playing, resume all with fade
291
+ if (hasPlayingChannel) {
292
+ yield (0, exports.pauseAllWithFade)(fadeType, duration);
293
+ }
294
+ else {
295
+ yield (0, exports.resumeAllWithFade)(fadeType, duration);
296
+ }
297
+ });
298
+ exports.togglePauseAllWithFade = togglePauseAllWithFade;
299
+ /**
300
+ * Pauses the currently playing audio in a specific channel
301
+ * @param channelNumber - The channel number to pause (defaults to 0)
302
+ * @returns Promise that resolves when the audio is paused
303
+ * @example
304
+ * ```typescript
305
+ * await pauseChannel(0); // Pause audio in channel 0
306
+ * await pauseChannel(); // Pause audio in default channel
307
+ * ```
308
+ */
309
+ const pauseChannel = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (channelNumber = 0) {
310
+ const channel = info_1.audioChannels[channelNumber];
311
+ if (channel && channel.queue.length > 0) {
312
+ const currentAudio = channel.queue[0];
313
+ if (!currentAudio.paused && !currentAudio.ended) {
314
+ currentAudio.pause();
315
+ channel.isPaused = true;
316
+ const audioInfo = (0, utils_1.getAudioInfoFromElement)(currentAudio, channelNumber, info_1.audioChannels);
317
+ if (audioInfo) {
318
+ (0, events_1.emitAudioPause)(channelNumber, audioInfo, info_1.audioChannels);
319
+ }
320
+ }
321
+ }
322
+ });
323
+ exports.pauseChannel = pauseChannel;
324
+ /**
325
+ * Resumes the currently paused audio in a specific channel
326
+ * @param channelNumber - The channel number to resume (defaults to 0)
327
+ * @returns Promise that resolves when the audio starts playing
328
+ * @example
329
+ * ```typescript
330
+ * await resumeChannel(0); // Resume audio in channel 0
331
+ * await resumeChannel(); // Resume audio in default channel
332
+ * ```
333
+ */
334
+ const resumeChannel = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (channelNumber = 0) {
335
+ const channel = info_1.audioChannels[channelNumber];
336
+ if (channel && channel.queue.length > 0) {
337
+ const currentAudio = channel.queue[0];
338
+ // Only resume if both the channel is marked as paused AND the audio element is actually paused AND not ended
339
+ if (channel.isPaused && currentAudio.paused && !currentAudio.ended) {
340
+ yield currentAudio.play();
341
+ channel.isPaused = false;
342
+ const audioInfo = (0, utils_1.getAudioInfoFromElement)(currentAudio, channelNumber, info_1.audioChannels);
343
+ if (audioInfo) {
344
+ (0, events_1.emitAudioResume)(channelNumber, audioInfo, info_1.audioChannels);
345
+ }
346
+ }
347
+ }
348
+ });
349
+ exports.resumeChannel = resumeChannel;
350
+ /**
351
+ * Toggles pause/resume state for a specific channel
352
+ * @param channelNumber - The channel number to toggle (defaults to 0)
353
+ * @returns Promise that resolves when the toggle is complete
354
+ * @example
355
+ * ```typescript
356
+ * await togglePauseChannel(0); // Toggle pause state for channel 0
357
+ * ```
358
+ */
359
+ const togglePauseChannel = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (channelNumber = 0) {
360
+ const channel = info_1.audioChannels[channelNumber];
361
+ if (channel && channel.queue.length > 0) {
362
+ const currentAudio = channel.queue[0];
363
+ if (currentAudio.paused) {
364
+ yield (0, exports.resumeChannel)(channelNumber);
365
+ }
366
+ else {
367
+ yield (0, exports.pauseChannel)(channelNumber);
368
+ }
369
+ }
370
+ });
371
+ exports.togglePauseChannel = togglePauseChannel;
372
+ /**
373
+ * Pauses all currently playing audio across all channels
374
+ * @returns Promise that resolves when all audio is paused
375
+ * @example
376
+ * ```typescript
377
+ * await pauseAllChannels(); // Pause everything
378
+ * ```
379
+ */
380
+ const pauseAllChannels = () => __awaiter(void 0, void 0, void 0, function* () {
381
+ const pausePromises = [];
382
+ info_1.audioChannels.forEach((_channel, index) => {
383
+ pausePromises.push((0, exports.pauseChannel)(index));
384
+ });
385
+ yield Promise.all(pausePromises);
386
+ });
387
+ exports.pauseAllChannels = pauseAllChannels;
388
+ /**
389
+ * Resumes all currently paused audio across all channels
390
+ * @returns Promise that resolves when all audio is resumed
391
+ * @example
392
+ * ```typescript
393
+ * await resumeAllChannels(); // Resume everything that was paused
394
+ * ```
395
+ */
396
+ const resumeAllChannels = () => __awaiter(void 0, void 0, void 0, function* () {
397
+ const resumePromises = [];
398
+ info_1.audioChannels.forEach((_channel, index) => {
399
+ resumePromises.push((0, exports.resumeChannel)(index));
400
+ });
401
+ yield Promise.all(resumePromises);
402
+ });
403
+ exports.resumeAllChannels = resumeAllChannels;
404
+ /**
405
+ * Checks if a specific channel is currently paused
406
+ * @param channelNumber - The channel number to check (defaults to 0)
407
+ * @returns True if the channel is paused, false otherwise
408
+ * @example
409
+ * ```typescript
410
+ * const isPaused = isChannelPaused(0);
411
+ * console.log(`Channel 0 is ${isPaused ? 'paused' : 'playing'}`);
412
+ * ```
413
+ */
414
+ const isChannelPaused = (channelNumber = 0) => {
415
+ var _a;
416
+ const channel = info_1.audioChannels[channelNumber];
417
+ return (_a = channel === null || channel === void 0 ? void 0 : channel.isPaused) !== null && _a !== void 0 ? _a : false;
418
+ };
419
+ exports.isChannelPaused = isChannelPaused;
420
+ /**
421
+ * Gets the pause state of all channels
422
+ * @returns Array of boolean values indicating pause state for each channel
423
+ * @example
424
+ * ```typescript
425
+ * const pauseStates = getAllChannelsPauseState();
426
+ * pauseStates.forEach((isPaused, index) => {
427
+ * console.log(`Channel ${index}: ${isPaused ? 'paused' : 'playing'}`);
428
+ * });
429
+ * ```
430
+ */
431
+ const getAllChannelsPauseState = () => {
432
+ return info_1.audioChannels.map((channel) => { var _a; return (_a = channel === null || channel === void 0 ? void 0 : channel.isPaused) !== null && _a !== void 0 ? _a : false; });
433
+ };
434
+ exports.getAllChannelsPauseState = getAllChannelsPauseState;
435
+ /**
436
+ * Toggles pause/resume state for all channels globally
437
+ * If any channels are currently playing, all channels will be paused
438
+ * If all channels are paused, all channels will be resumed
439
+ * @returns Promise that resolves when the toggle is complete
440
+ * @example
441
+ * ```typescript
442
+ * await togglePauseAllChannels(); // Pause all if any are playing, resume all if all are paused
443
+ * ```
444
+ */
445
+ const togglePauseAllChannels = () => __awaiter(void 0, void 0, void 0, function* () {
446
+ let hasPlayingChannel = false;
447
+ // Check if any channel is currently playing
448
+ for (let i = 0; i < info_1.audioChannels.length; i++) {
449
+ const channel = info_1.audioChannels[i];
450
+ if (channel && channel.queue.length > 0) {
451
+ const currentAudio = channel.queue[0];
452
+ if (!currentAudio.paused && !currentAudio.ended) {
453
+ hasPlayingChannel = true;
454
+ break;
455
+ }
456
+ }
457
+ }
458
+ // If any channel is playing, pause all channels
459
+ // If no channels are playing, resume all channels
460
+ if (hasPlayingChannel) {
461
+ yield (0, exports.pauseAllChannels)();
462
+ }
463
+ else {
464
+ yield (0, exports.resumeAllChannels)();
465
+ }
466
+ });
467
+ exports.togglePauseAllChannels = togglePauseAllChannels;
@@ -0,0 +1,104 @@
1
+ /**
2
+ * @fileoverview Queue manipulation functions for the audioq package
3
+ * Provides advanced queue management including item removal, reordering, and clearing
4
+ */
5
+ import { QueueManipulationResult, QueueItem } from './types';
6
+ /**
7
+ * Removes a specific item from the queue by its slot number (0-based index)
8
+ * Cannot remove the currently playing item (index 0) - use stopCurrentAudioInChannel instead
9
+ * @param queuedSlotNumber - Zero-based index of the item to remove (must be > 0)
10
+ * @param channelNumber - The channel number (defaults to 0)
11
+ * @returns Promise resolving to operation result with success status and updated queue
12
+ * @throws Error if trying to remove currently playing item or invalid slot number
13
+ * @example
14
+ * ```typescript
15
+ * // Remove the second item in queue (index 1)
16
+ * const result = await removeQueuedItem(1, 0);
17
+ * if (result.success) {
18
+ * console.log(`Removed item, queue now has ${result.updatedQueue.totalItems} items`);
19
+ * }
20
+ *
21
+ * // Remove the third item from channel 1
22
+ * await removeQueuedItem(2, 1);
23
+ * ```
24
+ */
25
+ export declare const removeQueuedItem: (queuedSlotNumber: number, channelNumber?: number) => Promise<QueueManipulationResult>;
26
+ /**
27
+ * Reorders a queue item by moving it from one position to another
28
+ * Cannot reorder the currently playing item (index 0)
29
+ * @param currentQueuedSlotNumber - Current zero-based index of the item to move (must be > 0)
30
+ * @param newQueuedSlotNumber - New zero-based index where the item should be placed (must be > 0)
31
+ * @param channelNumber - The channel number (defaults to 0)
32
+ * @returns Promise resolving to operation result with success status and updated queue
33
+ * @throws Error if trying to reorder currently playing item or invalid slot numbers
34
+ * @example
35
+ * ```typescript
36
+ * // Move item from position 2 to position 1 (make it play next)
37
+ * const result = await reorderQueue(2, 1, 0);
38
+ * if (result.success) {
39
+ * console.log('Item moved successfully');
40
+ * }
41
+ *
42
+ * // Move item from position 1 to end of queue
43
+ * await reorderQueue(1, 4, 0); // Assuming queue has 5+ items
44
+ * ```
45
+ */
46
+ export declare const reorderQueue: (currentQueuedSlotNumber: number, newQueuedSlotNumber: number, channelNumber?: number) => Promise<QueueManipulationResult>;
47
+ /**
48
+ * Clears all queued audio items after the currently playing item
49
+ * The current audio will continue playing but nothing will follow it
50
+ * @param channelNumber - The channel number (defaults to 0)
51
+ * @returns Promise resolving to operation result with success status and updated queue
52
+ * @example
53
+ * ```typescript
54
+ * // Let current song finish but clear everything after it
55
+ * const result = await clearQueueAfterCurrent(0);
56
+ * if (result.success) {
57
+ * console.log(`Cleared queue, current audio will be the last to play`);
58
+ * }
59
+ * ```
60
+ */
61
+ export declare const clearQueueAfterCurrent: (channelNumber?: number) => Promise<QueueManipulationResult>;
62
+ /**
63
+ * Gets information about a specific queue item by its slot number
64
+ * @param queueSlotNumber - Zero-based index of the queue item
65
+ * @param channelNumber - The channel number (defaults to 0)
66
+ * @returns QueueItem information or null if slot doesn't exist
67
+ * @example
68
+ * ```typescript
69
+ * const itemInfo = getQueueItemInfo(1, 0);
70
+ * if (itemInfo) {
71
+ * console.log(`Next to play: ${itemInfo.fileName}`);
72
+ * console.log(`Duration: ${itemInfo.duration}ms`);
73
+ * }
74
+ * ```
75
+ */
76
+ export declare const getQueueItemInfo: (queueSlotNumber: number, channelNumber?: number) => QueueItem | null;
77
+ /**
78
+ * Gets the current queue length for a specific channel
79
+ * @param channelNumber - The channel number (defaults to 0)
80
+ * @returns Number of items in the queue, or 0 if channel doesn't exist
81
+ * @example
82
+ * ```typescript
83
+ * const queueSize = getQueueLength(0);
84
+ * console.log(`Channel 0 has ${queueSize} items in queue`);
85
+ * ```
86
+ */
87
+ export declare const getQueueLength: (channelNumber?: number) => number;
88
+ /**
89
+ * Swaps the positions of two queue items
90
+ * Cannot swap with the currently playing item (index 0)
91
+ * @param slotA - Zero-based index of first item to swap (must be > 0)
92
+ * @param slotB - Zero-based index of second item to swap (must be > 0)
93
+ * @param channelNumber - The channel number (defaults to 0)
94
+ * @returns Promise resolving to operation result with success status and updated queue
95
+ * @example
96
+ * ```typescript
97
+ * // Swap the second and third items in queue
98
+ * const result = await swapQueueItems(1, 2, 0);
99
+ * if (result.success) {
100
+ * console.log('Items swapped successfully');
101
+ * }
102
+ * ```
103
+ */
104
+ export declare const swapQueueItems: (slotA: number, slotB: number, channelNumber?: number) => Promise<QueueManipulationResult>;