@antha/audio 0.0.8 → 0.1.1

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,11 +1,47 @@
1
1
  # @antha/audio
2
2
 
3
- A pre-built [Antha](https://www.npmjs.com/package/antha) mod for handling audio.
4
-
5
- Demo: https://electrovir.github.io/antha/demo/audio
3
+ This package provides a pre-built [Antha game engine](https://www.npmjs.com/package/@antha/engine) mod for loading and playing audio in the browser.
6
4
 
7
5
  ## Install
8
6
 
9
7
  ```sh
10
8
  npm i @antha/audio
11
9
  ```
10
+
11
+ ## Usage
12
+
13
+ <!-- example-link: src/readme-examples/playing-audio.example.ts -->
14
+
15
+ ```TypeScript
16
+ import {AnthaEngine, defineAnthaMod} from '@antha/engine';
17
+ import {type AnthaAudioState, createAnthaAudioMod} from '@antha/audio';
18
+
19
+ type GameState = AnthaAudioState & {
20
+ shouldPlayJumpSound: boolean;
21
+ };
22
+
23
+ const engine = new AnthaEngine<GameState>({
24
+ initState: {
25
+ shouldPlayJumpSound: true,
26
+ },
27
+ mods: [
28
+ createAnthaAudioMod(),
29
+ defineAnthaMod<GameState>({
30
+ modName: 'game-logic',
31
+ execute({state}) {
32
+ if (state.audioPlayer && state.shouldPlayJumpSound) {
33
+ state.shouldPlayJumpSound = false;
34
+ void state.audioPlayer.play({
35
+ sources: [
36
+ '/audio/jump.ogg',
37
+ '/audio/jump.mp3',
38
+ ],
39
+ });
40
+ }
41
+ },
42
+ }),
43
+ ],
44
+ });
45
+
46
+ engine.startLoop();
47
+ ```
@@ -192,7 +192,7 @@ export declare function setupEffects(audioContext: Readonly<BaseAudioContext>, o
192
192
  * @category Internal
193
193
  */
194
194
  export declare class AudioFile extends ListenTarget<AllAudioFileEvents> {
195
- private readonly params;
195
+ protected readonly params: AudioFileParams;
196
196
  /**
197
197
  * The url or base64 string chosen from the originally provided list of sources that is most
198
198
  * compatible with the current browser. This is what will be played.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antha/audio",
3
- "version": "0.0.8",
3
+ "version": "0.1.1",
4
4
  "description": "An Antha mod for handling audio.",
5
5
  "keywords": [
6
6
  "vir",
@@ -33,17 +33,17 @@
33
33
  "test:docs": "virmator docs check"
34
34
  },
35
35
  "dependencies": {
36
- "@augment-vir/assert": "^31.73.1",
37
- "@augment-vir/common": "^31.73.1"
36
+ "@augment-vir/assert": "^32.2.2",
37
+ "@augment-vir/common": "^32.2.2"
38
38
  },
39
39
  "devDependencies": {
40
- "@antha/engine": "^0.0.8",
41
- "@augment-vir/test": "^31.73.1",
42
- "@web/dev-server-esbuild": "^1.0.5",
43
- "@web/test-runner": "^0.20.2",
44
- "@web/test-runner-playwright": "^0.11.1",
40
+ "@antha/engine": "^0.1.1",
41
+ "@augment-vir/test": "^32.2.2",
42
+ "@web/dev-server-esbuild": "^2.0.0",
43
+ "@web/test-runner": "^1.0.0",
44
+ "@web/test-runner-playwright": "^1.0.0",
45
45
  "istanbul-smart-text-reporter": "^1.1.5",
46
- "typed-event-target": "^4.3.1"
46
+ "typed-event-target": "^4.3.3"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@antha/engine": "*",