@vapi-ai/web 1.0.10 → 1.0.12

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/player.d.ts CHANGED
@@ -5,6 +5,7 @@ export declare class ContinuousPlayer extends EventEmitter {
5
5
  private sourceBuffer;
6
6
  private audio;
7
7
  constructor();
8
+ start(): void;
8
9
  playChunk(audioData: ArrayBuffer): void;
9
10
  clear(): Promise<void>;
10
11
  }
package/dist/player.js CHANGED
@@ -18,14 +18,18 @@ class ContinuousPlayer extends events_1.default {
18
18
  constructor() {
19
19
  super();
20
20
  this.sourceBuffer = null;
21
+ this.audio = null;
21
22
  this.mediaSource = new MediaSource();
22
- this.audio = new Audio();
23
- this.audio.src = URL.createObjectURL(this.mediaSource);
24
- this.audio.play();
25
23
  this.mediaSource.onsourceopen = () => {
26
24
  this.sourceBuffer = this.mediaSource.addSourceBuffer('audio/webm; codecs="opus"');
25
+ this.audio = new Audio();
26
+ this.audio.src = URL.createObjectURL(this.mediaSource);
27
27
  };
28
28
  }
29
+ start() {
30
+ var _a;
31
+ (_a = this.audio) === null || _a === void 0 ? void 0 : _a.play();
32
+ }
29
33
  playChunk(audioData) {
30
34
  if (!this.sourceBuffer)
31
35
  return;
package/dist/vapi.js CHANGED
@@ -23,6 +23,7 @@ class Vapi extends events_1.default {
23
23
  return;
24
24
  }
25
25
  this.started = true;
26
+ this.player.start();
26
27
  client_1.client.call
27
28
  .callControllerCreateWebCall({
28
29
  agent: typeof agent === "string" ? undefined : agent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vapi-ai/web",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "",
5
5
  "main": "dist/vapi.js",
6
6
  "types": "dist/vapi.d.ts",
package/player.ts CHANGED
@@ -3,22 +3,25 @@ import EventEmitter from "events";
3
3
  export class ContinuousPlayer extends EventEmitter {
4
4
  private mediaSource: MediaSource;
5
5
  private sourceBuffer: SourceBuffer | null = null;
6
- private audio: HTMLAudioElement;
6
+ private audio: HTMLAudioElement | null = null;
7
7
 
8
8
  constructor() {
9
9
  super();
10
10
  this.mediaSource = new MediaSource();
11
- this.audio = new Audio();
12
- this.audio.src = URL.createObjectURL(this.mediaSource);
13
- this.audio.play();
14
11
 
15
12
  this.mediaSource.onsourceopen = () => {
16
13
  this.sourceBuffer = this.mediaSource.addSourceBuffer(
17
14
  'audio/webm; codecs="opus"'
18
15
  );
16
+ this.audio = new Audio();
17
+ this.audio.src = URL.createObjectURL(this.mediaSource);
19
18
  };
20
19
  }
21
20
 
21
+ start() {
22
+ this.audio?.play();
23
+ }
24
+
22
25
  playChunk(audioData: ArrayBuffer) {
23
26
  if (!this.sourceBuffer) return;
24
27
  console.log(this.mediaSource.readyState, this.sourceBuffer.updating);
package/vapi.ts CHANGED
@@ -26,6 +26,7 @@ export default class Vapi extends EventEmitter {
26
26
  }
27
27
 
28
28
  this.started = true;
29
+ this.player.start();
29
30
 
30
31
  client.call
31
32
  .callControllerCreateWebCall({