audio-channel-queue 1.5.0 → 1.6.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 CHANGED
@@ -12,39 +12,95 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
12
12
  });
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.stopAllAudio = exports.stopAllAudioInChannel = exports.stopCurrentAudioInChannel = exports.playAudioQueue = exports.queueAudio = void 0;
15
+ exports.stopAllAudio = exports.stopAllAudioInChannel = exports.stopCurrentAudioInChannel = exports.playAudioQueue = exports.queueAudioPriority = exports.queueAudio = void 0;
16
16
  const info_1 = require("./info");
17
17
  const utils_1 = require("./utils");
18
18
  const events_1 = require("./events");
19
+ const volume_1 = require("./volume");
19
20
  /**
20
21
  * Queues an audio file to a specific channel and starts playing if it's the first in queue
21
22
  * @param audioUrl - The URL of the audio file to queue
22
23
  * @param channelNumber - The channel number to queue the audio to (defaults to 0)
24
+ * @param options - Optional configuration for the audio file
23
25
  * @returns Promise that resolves when the audio is queued and starts playing (if first in queue)
24
26
  * @example
25
27
  * ```typescript
26
28
  * await queueAudio('https://example.com/song.mp3', 0);
27
29
  * await queueAudio('./sounds/notification.wav'); // Uses default channel 0
30
+ * await queueAudio('./music/loop.mp3', 1, { loop: true }); // Loop the audio
31
+ * await queueAudio('./urgent.wav', 0, { addToFront: true }); // Add to front of queue
28
32
  * ```
29
33
  */
30
- const queueAudio = (audioUrl_1, ...args_1) => __awaiter(void 0, [audioUrl_1, ...args_1], void 0, function* (audioUrl, channelNumber = 0) {
34
+ const queueAudio = (audioUrl_1, ...args_1) => __awaiter(void 0, [audioUrl_1, ...args_1], void 0, function* (audioUrl, channelNumber = 0, options) {
31
35
  if (!info_1.audioChannels[channelNumber]) {
32
36
  info_1.audioChannels[channelNumber] = {
33
37
  audioCompleteCallbacks: new Set(),
38
+ audioPauseCallbacks: new Set(),
39
+ audioResumeCallbacks: new Set(),
34
40
  audioStartCallbacks: new Set(),
41
+ isPaused: false,
35
42
  progressCallbacks: new Map(),
36
43
  queue: [],
37
- queueChangeCallbacks: new Set()
44
+ queueChangeCallbacks: new Set(),
45
+ volume: 1.0
38
46
  };
39
47
  }
40
48
  const audio = new Audio(audioUrl);
41
- info_1.audioChannels[channelNumber].queue.push(audio);
49
+ // Apply audio configuration from options
50
+ if (options === null || options === void 0 ? void 0 : options.loop) {
51
+ audio.loop = true;
52
+ }
53
+ if ((options === null || options === void 0 ? void 0 : options.volume) !== undefined) {
54
+ const clampedVolume = Math.max(0, Math.min(1, options.volume));
55
+ // Handle NaN case - default to channel volume or 1.0
56
+ const safeVolume = isNaN(clampedVolume) ? (info_1.audioChannels[channelNumber].volume || 1.0) : clampedVolume;
57
+ audio.volume = safeVolume;
58
+ // Also update the channel volume
59
+ info_1.audioChannels[channelNumber].volume = safeVolume;
60
+ }
61
+ else {
62
+ // Use channel volume if no specific volume is set
63
+ const channelVolume = info_1.audioChannels[channelNumber].volume || 1.0;
64
+ audio.volume = channelVolume;
65
+ }
66
+ // Add to front or back of queue based on options
67
+ if (((options === null || options === void 0 ? void 0 : options.addToFront) || (options === null || options === void 0 ? void 0 : options.priority)) && info_1.audioChannels[channelNumber].queue.length > 0) {
68
+ // Insert after the currently playing audio (index 1)
69
+ info_1.audioChannels[channelNumber].queue.splice(1, 0, audio);
70
+ }
71
+ else if (((options === null || options === void 0 ? void 0 : options.addToFront) || (options === null || options === void 0 ? void 0 : options.priority)) && info_1.audioChannels[channelNumber].queue.length === 0) {
72
+ // If queue is empty, just add normally
73
+ info_1.audioChannels[channelNumber].queue.push(audio);
74
+ }
75
+ else {
76
+ // Default behavior - add to back of queue
77
+ info_1.audioChannels[channelNumber].queue.push(audio);
78
+ }
42
79
  (0, events_1.emitQueueChange)(channelNumber, info_1.audioChannels);
43
80
  if (info_1.audioChannels[channelNumber].queue.length === 1) {
44
- (0, exports.playAudioQueue)(channelNumber);
81
+ // Don't await - let playback happen asynchronously
82
+ (0, exports.playAudioQueue)(channelNumber).catch(console.error);
45
83
  }
46
84
  });
47
85
  exports.queueAudio = queueAudio;
86
+ /**
87
+ * Adds an audio file to the front of the queue in a specific channel
88
+ * This is a convenience function that places the audio right after the currently playing track
89
+ * @param audioUrl - The URL of the audio file to queue
90
+ * @param channelNumber - The channel number to queue the audio to (defaults to 0)
91
+ * @param options - Optional configuration for the audio file
92
+ * @returns Promise that resolves when the audio is queued
93
+ * @example
94
+ * ```typescript
95
+ * await queueAudioPriority('./urgent-announcement.wav', 0);
96
+ * await queueAudioPriority('./priority-sound.mp3', 1, { loop: true });
97
+ * ```
98
+ */
99
+ const queueAudioPriority = (audioUrl_1, ...args_1) => __awaiter(void 0, [audioUrl_1, ...args_1], void 0, function* (audioUrl, channelNumber = 0, options) {
100
+ const priorityOptions = Object.assign(Object.assign({}, options), { addToFront: true });
101
+ return (0, exports.queueAudio)(audioUrl, channelNumber, priorityOptions);
102
+ });
103
+ exports.queueAudioPriority = queueAudioPriority;
48
104
  /**
49
105
  * Plays the audio queue for a specific channel
50
106
  * @param channelNumber - The channel number to play
@@ -56,10 +112,16 @@ exports.queueAudio = queueAudio;
56
112
  */
57
113
  const playAudioQueue = (channelNumber) => __awaiter(void 0, void 0, void 0, function* () {
58
114
  const channel = info_1.audioChannels[channelNumber];
59
- if (channel.queue.length === 0)
115
+ if (!channel || channel.queue.length === 0)
60
116
  return;
61
117
  const currentAudio = channel.queue[0];
118
+ // Apply channel volume if not already set
119
+ if (currentAudio.volume === 1.0 && channel.volume !== undefined) {
120
+ currentAudio.volume = channel.volume;
121
+ }
62
122
  (0, events_1.setupProgressTracking)(currentAudio, channelNumber, info_1.audioChannels);
123
+ // Apply volume ducking when audio starts
124
+ yield (0, volume_1.applyVolumeDucking)(channelNumber);
63
125
  return new Promise((resolve) => {
64
126
  let hasStarted = false;
65
127
  let metadataLoaded = false;
@@ -94,16 +156,29 @@ const playAudioQueue = (channelNumber) => __awaiter(void 0, void 0, void 0, func
94
156
  remainingInQueue: channel.queue.length - 1,
95
157
  src: currentAudio.src
96
158
  }, info_1.audioChannels);
159
+ // Restore volume levels when priority channel stops
160
+ yield (0, volume_1.restoreVolumeLevels)(channelNumber);
97
161
  // Clean up event listeners
98
162
  currentAudio.removeEventListener('loadedmetadata', handleLoadedMetadata);
99
163
  currentAudio.removeEventListener('play', handlePlay);
100
164
  currentAudio.removeEventListener('ended', handleEnded);
101
165
  (0, events_1.cleanupProgressTracking)(currentAudio, channelNumber, info_1.audioChannels);
102
- channel.queue.shift();
103
- // Emit queue change after completion
104
- setTimeout(() => (0, events_1.emitQueueChange)(channelNumber, info_1.audioChannels), 10);
105
- yield (0, exports.playAudioQueue)(channelNumber);
106
- resolve();
166
+ // Handle looping vs non-looping audio
167
+ if (currentAudio.loop) {
168
+ // For looping audio, reset current time and continue playing
169
+ currentAudio.currentTime = 0;
170
+ yield currentAudio.play();
171
+ // Don't remove from queue, but resolve the promise so tests don't hang
172
+ resolve();
173
+ }
174
+ else {
175
+ // For non-looping audio, remove from queue and play next
176
+ channel.queue.shift();
177
+ // Emit queue change after completion
178
+ setTimeout(() => (0, events_1.emitQueueChange)(channelNumber, info_1.audioChannels), 10);
179
+ yield (0, exports.playAudioQueue)(channelNumber);
180
+ resolve();
181
+ }
107
182
  });
108
183
  // Add event listeners
109
184
  currentAudio.addEventListener('loadedmetadata', handleLoadedMetadata);
@@ -122,11 +197,11 @@ exports.playAudioQueue = playAudioQueue;
122
197
  * @param channelNumber - The channel number (defaults to 0)
123
198
  * @example
124
199
  * ```typescript
125
- * stopCurrentAudioInChannel(0); // Stop current audio in channel 0
126
- * stopCurrentAudioInChannel(); // Stop current audio in default channel
200
+ * await stopCurrentAudioInChannel(); // Stop current audio in default channel (0)
201
+ * await stopCurrentAudioInChannel(1); // Stop current audio in channel 1
127
202
  * ```
128
203
  */
129
- const stopCurrentAudioInChannel = (channelNumber = 0) => {
204
+ const stopCurrentAudioInChannel = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (channelNumber = 0) {
130
205
  const channel = info_1.audioChannels[channelNumber];
131
206
  if (channel && channel.queue.length > 0) {
132
207
  const currentAudio = channel.queue[0];
@@ -136,24 +211,28 @@ const stopCurrentAudioInChannel = (channelNumber = 0) => {
136
211
  remainingInQueue: channel.queue.length - 1,
137
212
  src: currentAudio.src
138
213
  }, info_1.audioChannels);
214
+ // Restore volume levels when stopping
215
+ yield (0, volume_1.restoreVolumeLevels)(channelNumber);
139
216
  currentAudio.pause();
140
217
  (0, events_1.cleanupProgressTracking)(currentAudio, channelNumber, info_1.audioChannels);
141
218
  channel.queue.shift();
219
+ channel.isPaused = false; // Reset pause state
142
220
  (0, events_1.emitQueueChange)(channelNumber, info_1.audioChannels);
143
- (0, exports.playAudioQueue)(channelNumber);
221
+ // Start next audio without waiting for it to complete
222
+ (0, exports.playAudioQueue)(channelNumber).catch(console.error);
144
223
  }
145
- };
224
+ });
146
225
  exports.stopCurrentAudioInChannel = stopCurrentAudioInChannel;
147
226
  /**
148
227
  * Stops all audio in a specific channel and clears the entire queue
149
228
  * @param channelNumber - The channel number (defaults to 0)
150
229
  * @example
151
230
  * ```typescript
152
- * stopAllAudioInChannel(0); // Clear all audio in channel 0
153
- * stopAllAudioInChannel(); // Clear all audio in default channel
231
+ * await stopAllAudioInChannel(); // Clear all audio in default channel (0)
232
+ * await stopAllAudioInChannel(1); // Clear all audio in channel 1
154
233
  * ```
155
234
  */
156
- const stopAllAudioInChannel = (channelNumber = 0) => {
235
+ const stopAllAudioInChannel = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (channelNumber = 0) {
157
236
  const channel = info_1.audioChannels[channelNumber];
158
237
  if (channel) {
159
238
  if (channel.queue.length > 0) {
@@ -164,26 +243,31 @@ const stopAllAudioInChannel = (channelNumber = 0) => {
164
243
  remainingInQueue: 0, // Will be 0 since we're clearing the queue
165
244
  src: currentAudio.src
166
245
  }, info_1.audioChannels);
246
+ // Restore volume levels when stopping
247
+ yield (0, volume_1.restoreVolumeLevels)(channelNumber);
167
248
  currentAudio.pause();
168
249
  (0, events_1.cleanupProgressTracking)(currentAudio, channelNumber, info_1.audioChannels);
169
250
  }
170
251
  // Clean up all progress tracking for this channel
171
252
  channel.queue.forEach(audio => (0, events_1.cleanupProgressTracking)(audio, channelNumber, info_1.audioChannels));
172
253
  channel.queue = [];
254
+ channel.isPaused = false; // Reset pause state
173
255
  (0, events_1.emitQueueChange)(channelNumber, info_1.audioChannels);
174
256
  }
175
- };
257
+ });
176
258
  exports.stopAllAudioInChannel = stopAllAudioInChannel;
177
259
  /**
178
260
  * Stops all audio across all channels and clears all queues
179
261
  * @example
180
262
  * ```typescript
181
- * stopAllAudio(); // Emergency stop - clears everything
263
+ * await stopAllAudio(); // Emergency stop - clears everything
182
264
  * ```
183
265
  */
184
- const stopAllAudio = () => {
266
+ const stopAllAudio = () => __awaiter(void 0, void 0, void 0, function* () {
267
+ const stopPromises = [];
185
268
  info_1.audioChannels.forEach((_channel, index) => {
186
- (0, exports.stopAllAudioInChannel)(index);
269
+ stopPromises.push((0, exports.stopAllAudioInChannel)(index));
187
270
  });
188
- };
271
+ yield Promise.all(stopPromises);
272
+ });
189
273
  exports.stopAllAudio = stopAllAudio;
package/dist/events.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Event handling and emission for the audio-channel-queue package
3
3
  */
4
- import { AudioStartInfo, AudioCompleteInfo, ExtendedAudioQueueChannel } from './types';
4
+ import { AudioStartInfo, AudioCompleteInfo, ExtendedAudioQueueChannel, AudioInfo } from './types';
5
5
  /**
6
6
  * Emits a queue change event to all registered listeners for a specific channel
7
7
  * @param channelNumber - The channel number that experienced a queue change
@@ -34,6 +34,28 @@ export declare const emitAudioStart: (channelNumber: number, audioInfo: AudioSta
34
34
  * ```
35
35
  */
36
36
  export declare const emitAudioComplete: (channelNumber: number, audioInfo: AudioCompleteInfo, audioChannels: ExtendedAudioQueueChannel[]) => void;
37
+ /**
38
+ * Emits an audio pause event to all registered listeners for a specific channel
39
+ * @param channelNumber - The channel number where audio was paused
40
+ * @param audioInfo - Information about the audio that was paused
41
+ * @param audioChannels - Array of audio channels
42
+ * @example
43
+ * ```typescript
44
+ * emitAudioPause(0, audioInfo, audioChannels);
45
+ * ```
46
+ */
47
+ export declare const emitAudioPause: (channelNumber: number, audioInfo: AudioInfo, audioChannels: ExtendedAudioQueueChannel[]) => void;
48
+ /**
49
+ * Emits an audio resume event to all registered listeners for a specific channel
50
+ * @param channelNumber - The channel number where audio was resumed
51
+ * @param audioInfo - Information about the audio that was resumed
52
+ * @param audioChannels - Array of audio channels
53
+ * @example
54
+ * ```typescript
55
+ * emitAudioResume(0, audioInfo, audioChannels);
56
+ * ```
57
+ */
58
+ export declare const emitAudioResume: (channelNumber: number, audioInfo: AudioInfo, audioChannels: ExtendedAudioQueueChannel[]) => void;
37
59
  /**
38
60
  * Sets up comprehensive progress tracking for an audio element
39
61
  * @param audio - The HTML audio element to track
package/dist/events.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * @fileoverview Event handling and emission for the audio-channel-queue package
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.cleanupProgressTracking = exports.setupProgressTracking = exports.emitAudioComplete = exports.emitAudioStart = exports.emitQueueChange = void 0;
6
+ exports.cleanupProgressTracking = exports.setupProgressTracking = exports.emitAudioResume = exports.emitAudioPause = exports.emitAudioComplete = exports.emitAudioStart = exports.emitQueueChange = void 0;
7
7
  const utils_1 = require("./utils");
8
8
  /**
9
9
  * Emits a queue change event to all registered listeners for a specific channel
@@ -79,6 +79,54 @@ const emitAudioComplete = (channelNumber, audioInfo, audioChannels) => {
79
79
  });
80
80
  };
81
81
  exports.emitAudioComplete = emitAudioComplete;
82
+ /**
83
+ * Emits an audio pause event to all registered listeners for a specific channel
84
+ * @param channelNumber - The channel number where audio was paused
85
+ * @param audioInfo - Information about the audio that was paused
86
+ * @param audioChannels - Array of audio channels
87
+ * @example
88
+ * ```typescript
89
+ * emitAudioPause(0, audioInfo, audioChannels);
90
+ * ```
91
+ */
92
+ const emitAudioPause = (channelNumber, audioInfo, audioChannels) => {
93
+ const channel = audioChannels[channelNumber];
94
+ if (!channel || !channel.audioPauseCallbacks)
95
+ return;
96
+ channel.audioPauseCallbacks.forEach(callback => {
97
+ try {
98
+ callback(channelNumber, audioInfo);
99
+ }
100
+ catch (error) {
101
+ console.error('Error in audio pause callback:', error);
102
+ }
103
+ });
104
+ };
105
+ exports.emitAudioPause = emitAudioPause;
106
+ /**
107
+ * Emits an audio resume event to all registered listeners for a specific channel
108
+ * @param channelNumber - The channel number where audio was resumed
109
+ * @param audioInfo - Information about the audio that was resumed
110
+ * @param audioChannels - Array of audio channels
111
+ * @example
112
+ * ```typescript
113
+ * emitAudioResume(0, audioInfo, audioChannels);
114
+ * ```
115
+ */
116
+ const emitAudioResume = (channelNumber, audioInfo, audioChannels) => {
117
+ const channel = audioChannels[channelNumber];
118
+ if (!channel || !channel.audioResumeCallbacks)
119
+ return;
120
+ channel.audioResumeCallbacks.forEach(callback => {
121
+ try {
122
+ callback(channelNumber, audioInfo);
123
+ }
124
+ catch (error) {
125
+ console.error('Error in audio resume callback:', error);
126
+ }
127
+ });
128
+ };
129
+ exports.emitAudioResume = emitAudioResume;
82
130
  // Store listener functions for cleanup
83
131
  const progressListeners = new WeakMap();
84
132
  /**
@@ -111,7 +159,7 @@ const setupProgressTracking = (audio, channelNumber, audioChannels) => {
111
159
  const allCallbacks = new Set([...audioCallbacks, ...channelCallbacks]);
112
160
  if (allCallbacks.size === 0)
113
161
  return;
114
- const info = (0, utils_1.getAudioInfoFromElement)(audio);
162
+ const info = (0, utils_1.getAudioInfoFromElement)(audio, channelNumber, audioChannels);
115
163
  if (info) {
116
164
  allCallbacks.forEach((callback) => {
117
165
  try {
package/dist/index.d.ts CHANGED
@@ -2,11 +2,12 @@
2
2
  * @fileoverview Main entry point for the audio-channel-queue package
3
3
  *
4
4
  * A comprehensive audio queue management system with real-time progress tracking,
5
- * multi-channel support, and extensive event handling capabilities.
5
+ * multi-channel support, pause/resume functionality, volume control with ducking,
6
+ * looping capabilities, and extensive event handling.
6
7
  *
7
8
  * @example Basic Usage
8
9
  * ```typescript
9
- * import { queueAudio, onAudioProgress } from 'audio-channel-queue';
10
+ * import { queueAudio, onAudioProgress, pauseChannel } from 'audio-channel-queue';
10
11
  *
11
12
  * // Queue an audio file
12
13
  * await queueAudio('song.mp3');
@@ -15,9 +16,14 @@
15
16
  * onAudioProgress(0, (info) => {
16
17
  * console.log(`Progress: ${info.progress * 100}%`);
17
18
  * });
19
+ *
20
+ * // Pause playback
21
+ * await pauseChannel(0);
18
22
  * ```
19
23
  */
20
- export type { AudioCompleteCallback, AudioCompleteInfo, AudioInfo, AudioQueue, AudioQueueChannel, AudioStartCallback, AudioStartInfo, ExtendedAudioQueueChannel, ProgressCallback, QueueChangeCallback, QueueItem, QueueSnapshot } from './types';
21
- export { playAudioQueue, queueAudio, stopAllAudio, stopAllAudioInChannel, stopCurrentAudioInChannel } from './core';
22
- export { audioChannels, getAllChannelsInfo, getCurrentAudioInfo, getQueueSnapshot, offAudioProgress, onAudioComplete, onAudioProgress, onAudioStart, onQueueChange, offQueueChange } from './info';
24
+ export type { AudioCompleteCallback, AudioCompleteInfo, AudioInfo, AudioPauseCallback, AudioQueue, AudioQueueChannel, AudioQueueOptions, AudioResumeCallback, AudioStartCallback, AudioStartInfo, ExtendedAudioQueueChannel, ProgressCallback, QueueChangeCallback, QueueItem, QueueSnapshot, VolumeConfig } from './types';
25
+ export { playAudioQueue, queueAudio, queueAudioPriority, stopAllAudio, stopAllAudioInChannel, stopCurrentAudioInChannel } from './core';
26
+ export { getAllChannelsPauseState, isChannelPaused, pauseAllChannels, pauseChannel, resumeAllChannels, resumeChannel, togglePauseAllChannels, togglePauseChannel } from './pause';
27
+ export { applyVolumeDucking, clearVolumeDucking, getAllChannelsVolume, getChannelVolume, restoreVolumeLevels, setAllChannelsVolume, setChannelVolume, setVolumeDucking, transitionVolume } from './volume';
28
+ export { audioChannels, getAllChannelsInfo, getCurrentAudioInfo, getQueueSnapshot, offAudioPause, offAudioProgress, offAudioResume, offQueueChange, onAudioComplete, onAudioPause, onAudioProgress, onAudioResume, onAudioStart, onQueueChange } from './info';
23
29
  export { cleanWebpackFilename, createQueueSnapshot, extractFileName, getAudioInfoFromElement } from './utils';
package/dist/index.js CHANGED
@@ -3,11 +3,12 @@
3
3
  * @fileoverview Main entry point for the audio-channel-queue package
4
4
  *
5
5
  * A comprehensive audio queue management system with real-time progress tracking,
6
- * multi-channel support, and extensive event handling capabilities.
6
+ * multi-channel support, pause/resume functionality, volume control with ducking,
7
+ * looping capabilities, and extensive event handling.
7
8
  *
8
9
  * @example Basic Usage
9
10
  * ```typescript
10
- * import { queueAudio, onAudioProgress } from 'audio-channel-queue';
11
+ * import { queueAudio, onAudioProgress, pauseChannel } from 'audio-channel-queue';
11
12
  *
12
13
  * // Queue an audio file
13
14
  * await queueAudio('song.mp3');
@@ -16,29 +17,58 @@
16
17
  * onAudioProgress(0, (info) => {
17
18
  * console.log(`Progress: ${info.progress * 100}%`);
18
19
  * });
20
+ *
21
+ * // Pause playback
22
+ * await pauseChannel(0);
19
23
  * ```
20
24
  */
21
25
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.getAudioInfoFromElement = exports.extractFileName = exports.createQueueSnapshot = exports.cleanWebpackFilename = exports.offQueueChange = exports.onQueueChange = exports.onAudioStart = exports.onAudioProgress = exports.onAudioComplete = exports.offAudioProgress = exports.getQueueSnapshot = exports.getCurrentAudioInfo = exports.getAllChannelsInfo = exports.audioChannels = exports.stopCurrentAudioInChannel = exports.stopAllAudioInChannel = exports.stopAllAudio = exports.queueAudio = exports.playAudioQueue = void 0;
26
+ exports.getAudioInfoFromElement = exports.extractFileName = exports.createQueueSnapshot = exports.cleanWebpackFilename = exports.onQueueChange = exports.onAudioStart = exports.onAudioResume = exports.onAudioProgress = exports.onAudioPause = exports.onAudioComplete = exports.offQueueChange = exports.offAudioResume = exports.offAudioProgress = exports.offAudioPause = exports.getQueueSnapshot = exports.getCurrentAudioInfo = exports.getAllChannelsInfo = exports.audioChannels = exports.transitionVolume = exports.setVolumeDucking = exports.setChannelVolume = exports.setAllChannelsVolume = exports.restoreVolumeLevels = exports.getChannelVolume = exports.getAllChannelsVolume = exports.clearVolumeDucking = exports.applyVolumeDucking = exports.togglePauseChannel = exports.togglePauseAllChannels = exports.resumeChannel = exports.resumeAllChannels = exports.pauseChannel = exports.pauseAllChannels = exports.isChannelPaused = exports.getAllChannelsPauseState = exports.stopCurrentAudioInChannel = exports.stopAllAudioInChannel = exports.stopAllAudio = exports.queueAudioPriority = exports.queueAudio = exports.playAudioQueue = void 0;
23
27
  // Export core queue management functions
24
28
  var core_1 = require("./core");
25
29
  Object.defineProperty(exports, "playAudioQueue", { enumerable: true, get: function () { return core_1.playAudioQueue; } });
26
30
  Object.defineProperty(exports, "queueAudio", { enumerable: true, get: function () { return core_1.queueAudio; } });
31
+ Object.defineProperty(exports, "queueAudioPriority", { enumerable: true, get: function () { return core_1.queueAudioPriority; } });
27
32
  Object.defineProperty(exports, "stopAllAudio", { enumerable: true, get: function () { return core_1.stopAllAudio; } });
28
33
  Object.defineProperty(exports, "stopAllAudioInChannel", { enumerable: true, get: function () { return core_1.stopAllAudioInChannel; } });
29
34
  Object.defineProperty(exports, "stopCurrentAudioInChannel", { enumerable: true, get: function () { return core_1.stopCurrentAudioInChannel; } });
35
+ // Export pause and resume functionality
36
+ var pause_1 = require("./pause");
37
+ Object.defineProperty(exports, "getAllChannelsPauseState", { enumerable: true, get: function () { return pause_1.getAllChannelsPauseState; } });
38
+ Object.defineProperty(exports, "isChannelPaused", { enumerable: true, get: function () { return pause_1.isChannelPaused; } });
39
+ Object.defineProperty(exports, "pauseAllChannels", { enumerable: true, get: function () { return pause_1.pauseAllChannels; } });
40
+ Object.defineProperty(exports, "pauseChannel", { enumerable: true, get: function () { return pause_1.pauseChannel; } });
41
+ Object.defineProperty(exports, "resumeAllChannels", { enumerable: true, get: function () { return pause_1.resumeAllChannels; } });
42
+ Object.defineProperty(exports, "resumeChannel", { enumerable: true, get: function () { return pause_1.resumeChannel; } });
43
+ Object.defineProperty(exports, "togglePauseAllChannels", { enumerable: true, get: function () { return pause_1.togglePauseAllChannels; } });
44
+ Object.defineProperty(exports, "togglePauseChannel", { enumerable: true, get: function () { return pause_1.togglePauseChannel; } });
45
+ // Export volume control functions
46
+ var volume_1 = require("./volume");
47
+ Object.defineProperty(exports, "applyVolumeDucking", { enumerable: true, get: function () { return volume_1.applyVolumeDucking; } });
48
+ Object.defineProperty(exports, "clearVolumeDucking", { enumerable: true, get: function () { return volume_1.clearVolumeDucking; } });
49
+ Object.defineProperty(exports, "getAllChannelsVolume", { enumerable: true, get: function () { return volume_1.getAllChannelsVolume; } });
50
+ Object.defineProperty(exports, "getChannelVolume", { enumerable: true, get: function () { return volume_1.getChannelVolume; } });
51
+ Object.defineProperty(exports, "restoreVolumeLevels", { enumerable: true, get: function () { return volume_1.restoreVolumeLevels; } });
52
+ Object.defineProperty(exports, "setAllChannelsVolume", { enumerable: true, get: function () { return volume_1.setAllChannelsVolume; } });
53
+ Object.defineProperty(exports, "setChannelVolume", { enumerable: true, get: function () { return volume_1.setChannelVolume; } });
54
+ Object.defineProperty(exports, "setVolumeDucking", { enumerable: true, get: function () { return volume_1.setVolumeDucking; } });
55
+ Object.defineProperty(exports, "transitionVolume", { enumerable: true, get: function () { return volume_1.transitionVolume; } });
30
56
  // Export audio information and progress tracking functions
31
57
  var info_1 = require("./info");
32
58
  Object.defineProperty(exports, "audioChannels", { enumerable: true, get: function () { return info_1.audioChannels; } });
33
59
  Object.defineProperty(exports, "getAllChannelsInfo", { enumerable: true, get: function () { return info_1.getAllChannelsInfo; } });
34
60
  Object.defineProperty(exports, "getCurrentAudioInfo", { enumerable: true, get: function () { return info_1.getCurrentAudioInfo; } });
35
61
  Object.defineProperty(exports, "getQueueSnapshot", { enumerable: true, get: function () { return info_1.getQueueSnapshot; } });
62
+ Object.defineProperty(exports, "offAudioPause", { enumerable: true, get: function () { return info_1.offAudioPause; } });
36
63
  Object.defineProperty(exports, "offAudioProgress", { enumerable: true, get: function () { return info_1.offAudioProgress; } });
64
+ Object.defineProperty(exports, "offAudioResume", { enumerable: true, get: function () { return info_1.offAudioResume; } });
65
+ Object.defineProperty(exports, "offQueueChange", { enumerable: true, get: function () { return info_1.offQueueChange; } });
37
66
  Object.defineProperty(exports, "onAudioComplete", { enumerable: true, get: function () { return info_1.onAudioComplete; } });
67
+ Object.defineProperty(exports, "onAudioPause", { enumerable: true, get: function () { return info_1.onAudioPause; } });
38
68
  Object.defineProperty(exports, "onAudioProgress", { enumerable: true, get: function () { return info_1.onAudioProgress; } });
69
+ Object.defineProperty(exports, "onAudioResume", { enumerable: true, get: function () { return info_1.onAudioResume; } });
39
70
  Object.defineProperty(exports, "onAudioStart", { enumerable: true, get: function () { return info_1.onAudioStart; } });
40
71
  Object.defineProperty(exports, "onQueueChange", { enumerable: true, get: function () { return info_1.onQueueChange; } });
41
- Object.defineProperty(exports, "offQueueChange", { enumerable: true, get: function () { return info_1.offQueueChange; } });
42
72
  // Export utility functions (for advanced usage)
43
73
  var utils_1 = require("./utils");
44
74
  Object.defineProperty(exports, "cleanWebpackFilename", { enumerable: true, get: function () { return utils_1.cleanWebpackFilename; } });
package/dist/info.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Audio information and progress tracking functions for the audio-channel-queue package
3
3
  */
4
- import { AudioInfo, QueueSnapshot, ProgressCallback, QueueChangeCallback, AudioStartCallback, AudioCompleteCallback, ExtendedAudioQueueChannel } from './types';
4
+ import { AudioInfo, QueueSnapshot, ProgressCallback, QueueChangeCallback, AudioStartCallback, AudioCompleteCallback, AudioPauseCallback, AudioResumeCallback, ExtendedAudioQueueChannel } from './types';
5
5
  /**
6
6
  * Global array of extended audio queue channels
7
7
  */
@@ -120,3 +120,47 @@ export declare const onAudioStart: (channelNumber: number, callback: AudioStartC
120
120
  * ```
121
121
  */
122
122
  export declare const onAudioComplete: (channelNumber: number, callback: AudioCompleteCallback) => void;
123
+ /**
124
+ * Subscribes to audio pause events for a specific channel
125
+ * @param channelNumber - The channel number to monitor
126
+ * @param callback - Function to call when audio is paused
127
+ * @example
128
+ * ```typescript
129
+ * onAudioPause(0, (channelNumber, info) => {
130
+ * showPauseIndicator();
131
+ * logPauseEvent(info.fileName, info.currentTime);
132
+ * });
133
+ * ```
134
+ */
135
+ export declare const onAudioPause: (channelNumber: number, callback: AudioPauseCallback) => void;
136
+ /**
137
+ * Subscribes to audio resume events for a specific channel
138
+ * @param channelNumber - The channel number to monitor
139
+ * @param callback - Function to call when audio is resumed
140
+ * @example
141
+ * ```typescript
142
+ * onAudioResume(0, (channelNumber, info) => {
143
+ * hidePauseIndicator();
144
+ * logResumeEvent(info.fileName, info.currentTime);
145
+ * });
146
+ * ```
147
+ */
148
+ export declare const onAudioResume: (channelNumber: number, callback: AudioResumeCallback) => void;
149
+ /**
150
+ * Removes pause event listeners for a specific channel
151
+ * @param channelNumber - The channel number
152
+ * @example
153
+ * ```typescript
154
+ * offAudioPause(0); // Stop receiving pause notifications for channel 0
155
+ * ```
156
+ */
157
+ export declare const offAudioPause: (channelNumber: number) => void;
158
+ /**
159
+ * Removes resume event listeners for a specific channel
160
+ * @param channelNumber - The channel number
161
+ * @example
162
+ * ```typescript
163
+ * offAudioResume(0); // Stop receiving resume notifications for channel 0
164
+ * ```
165
+ */
166
+ export declare const offAudioResume: (channelNumber: number) => void;