audio-channel-queue 1.2.0 → 1.4.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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Audio Queue Package
1
+ # Audio Channel Queue
2
2
  The purpose of this package is to help queue audio files so they do not play on top of each other. You can also enqueue audio files to different queues. This allows you to play sounds concurrently, but not have them overlap in their given audio queue.
3
3
 
4
4
  This package offers TypeScript support 📘, boasts zero dependencies 🚫, and is released under the MIT license 📜. As an added bonus, it's NON-GMO 🌱 and 100% Free Range Organic 🐓.
package/dist/audio.d.ts CHANGED
@@ -4,6 +4,7 @@ export type AudioQueueChannel = {
4
4
  };
5
5
  export declare const audioChannels: AudioQueueChannel[];
6
6
  export declare const queueAudio: (audioUrl: string, channelNumber?: number) => Promise<void>;
7
+ export declare const playAudioQueue: (channelNumber: number) => Promise<void>;
7
8
  export declare const stopCurrentAudioInChannel: (channelNumber?: number) => void;
8
9
  export declare const stopAllAudioInChannel: (channelNumber?: number) => void;
9
10
  export declare const stopAllAudio: () => void;
package/dist/audio.js CHANGED
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.stopAllAudio = exports.stopAllAudioInChannel = exports.stopCurrentAudioInChannel = exports.queueAudio = exports.audioChannels = void 0;
12
+ exports.stopAllAudio = exports.stopAllAudioInChannel = exports.stopCurrentAudioInChannel = exports.playAudioQueue = exports.queueAudio = exports.audioChannels = void 0;
13
13
  exports.audioChannels = [];
14
14
  const queueAudio = (audioUrl_1, ...args_1) => __awaiter(void 0, [audioUrl_1, ...args_1], void 0, function* (audioUrl, channelNumber = 0) {
15
15
  if (!exports.audioChannels[channelNumber]) {
@@ -18,7 +18,7 @@ const queueAudio = (audioUrl_1, ...args_1) => __awaiter(void 0, [audioUrl_1, ...
18
18
  const audio = new Audio(audioUrl);
19
19
  exports.audioChannels[channelNumber].queue.push(audio);
20
20
  if (exports.audioChannels[channelNumber].queue.length === 1) {
21
- return playAudioQueue(channelNumber);
21
+ return (0, exports.playAudioQueue)(channelNumber);
22
22
  }
23
23
  });
24
24
  exports.queueAudio = queueAudio;
@@ -30,19 +30,20 @@ const playAudioQueue = (channelNumber) => __awaiter(void 0, void 0, void 0, func
30
30
  return new Promise((resolve) => {
31
31
  currentAudio.addEventListener('ended', () => __awaiter(void 0, void 0, void 0, function* () {
32
32
  channel.queue.shift();
33
- yield playAudioQueue(channelNumber);
33
+ yield (0, exports.playAudioQueue)(channelNumber);
34
34
  resolve();
35
35
  }));
36
36
  currentAudio.play();
37
37
  });
38
38
  });
39
+ exports.playAudioQueue = playAudioQueue;
39
40
  const stopCurrentAudioInChannel = (channelNumber = 0) => {
40
41
  const channel = exports.audioChannels[channelNumber];
41
42
  if (channel && channel.queue.length > 0) {
42
43
  const currentAudio = channel.queue[0];
43
44
  currentAudio.pause();
44
45
  channel.queue.shift();
45
- playAudioQueue(channelNumber);
46
+ (0, exports.playAudioQueue)(channelNumber);
46
47
  }
47
48
  };
48
49
  exports.stopCurrentAudioInChannel = stopCurrentAudioInChannel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "audio-channel-queue",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "Allows you to queue audio files to different playback channels.",
5
5
  "main": "dist/audio.js",
6
6
  "types": "dist/audio.d.ts",
@@ -10,7 +10,8 @@
10
10
  ],
11
11
  "scripts": {
12
12
  "build": "tsc",
13
- "prepare": "npm run build"
13
+ "prepare": "npm run build",
14
+ "test": "jest"
14
15
  },
15
16
  "repository": {
16
17
  "type": "git",
@@ -29,6 +30,9 @@
29
30
  },
30
31
  "homepage": "https://github.com/tonycarpenter21/audio-queue-package#readme",
31
32
  "devDependencies": {
33
+ "@types/jest": "^29.5.13",
34
+ "jest": "^29.7.0",
35
+ "ts-jest": "^29.2.5",
32
36
  "typescript": "^5.6.2"
33
37
  }
34
38
  }