@vapi-ai/web 1.0.43 → 1.0.45
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.js +4 -16
- package/package.json +1 -1
- package/player.ts +5 -21
package/dist/player.js
CHANGED
|
@@ -19,22 +19,6 @@ class ContinuousPlayer extends events_1.default {
|
|
|
19
19
|
this.sourceBuffer.addEventListener("updateend", () => {
|
|
20
20
|
this.appendNextChunk();
|
|
21
21
|
});
|
|
22
|
-
this.sourceBuffer.addEventListener("error", (e) => {
|
|
23
|
-
console.error("SourceBuffer error: ", e);
|
|
24
|
-
});
|
|
25
|
-
this.sourceBuffer.addEventListener("update", () => {
|
|
26
|
-
console.log("SourceBuffer is updating");
|
|
27
|
-
});
|
|
28
|
-
this.sourceBuffer.addEventListener("updateend", () => {
|
|
29
|
-
console.log("SourceBuffer finished updating");
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
this.mediaSource.addEventListener("sourceopen", () => {
|
|
33
|
-
console.log("MediaSource readyState: ", this.mediaSource.readyState);
|
|
34
|
-
// ...
|
|
35
|
-
});
|
|
36
|
-
this.mediaSource.addEventListener("error", (e) => {
|
|
37
|
-
console.error("MediaSource error: ", e);
|
|
38
22
|
});
|
|
39
23
|
}
|
|
40
24
|
start() {
|
|
@@ -51,6 +35,9 @@ class ContinuousPlayer extends events_1.default {
|
|
|
51
35
|
this.audioQueue.length > 0) {
|
|
52
36
|
const chunk = this.audioQueue.shift();
|
|
53
37
|
if (chunk) {
|
|
38
|
+
if (this.sourceBuffer.buffered.length > 0) {
|
|
39
|
+
this.sourceBuffer.timestampOffset = this.sourceBuffer.buffered.end(0);
|
|
40
|
+
}
|
|
54
41
|
this.sourceBuffer.appendBuffer(chunk);
|
|
55
42
|
console.log("appended", this.audioQueue.length);
|
|
56
43
|
}
|
|
@@ -69,6 +56,7 @@ class ContinuousPlayer extends events_1.default {
|
|
|
69
56
|
this.sourceBuffer.remove(0, this.sourceBuffer.buffered.end(0));
|
|
70
57
|
}
|
|
71
58
|
}
|
|
59
|
+
this.sourceBuffer.timestampOffset = 0;
|
|
72
60
|
}
|
|
73
61
|
}
|
|
74
62
|
}
|
package/package.json
CHANGED
package/player.ts
CHANGED
|
@@ -22,27 +22,6 @@ export class ContinuousPlayer extends EventEmitter {
|
|
|
22
22
|
this.sourceBuffer.addEventListener("updateend", () => {
|
|
23
23
|
this.appendNextChunk();
|
|
24
24
|
});
|
|
25
|
-
|
|
26
|
-
this.sourceBuffer.addEventListener("error", (e) => {
|
|
27
|
-
console.error("SourceBuffer error: ", e);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
this.sourceBuffer.addEventListener("update", () => {
|
|
31
|
-
console.log("SourceBuffer is updating");
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
this.sourceBuffer.addEventListener("updateend", () => {
|
|
35
|
-
console.log("SourceBuffer finished updating");
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
this.mediaSource.addEventListener("sourceopen", () => {
|
|
40
|
-
console.log("MediaSource readyState: ", this.mediaSource.readyState);
|
|
41
|
-
// ...
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
this.mediaSource.addEventListener("error", (e) => {
|
|
45
|
-
console.error("MediaSource error: ", e);
|
|
46
25
|
});
|
|
47
26
|
}
|
|
48
27
|
|
|
@@ -65,6 +44,10 @@ export class ContinuousPlayer extends EventEmitter {
|
|
|
65
44
|
) {
|
|
66
45
|
const chunk = this.audioQueue.shift();
|
|
67
46
|
if (chunk) {
|
|
47
|
+
if (this.sourceBuffer.buffered.length > 0) {
|
|
48
|
+
this.sourceBuffer.timestampOffset = this.sourceBuffer.buffered.end(0);
|
|
49
|
+
}
|
|
50
|
+
|
|
68
51
|
this.sourceBuffer.appendBuffer(chunk);
|
|
69
52
|
console.log("appended", this.audioQueue.length);
|
|
70
53
|
}
|
|
@@ -83,6 +66,7 @@ export class ContinuousPlayer extends EventEmitter {
|
|
|
83
66
|
this.sourceBuffer.remove(0, this.sourceBuffer.buffered.end(0));
|
|
84
67
|
}
|
|
85
68
|
}
|
|
69
|
+
this.sourceBuffer.timestampOffset = 0;
|
|
86
70
|
}
|
|
87
71
|
}
|
|
88
72
|
}
|