@vapi-ai/web 1.0.90 → 1.0.92
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 +1 -0
- package/dist/player.js +20 -7
- package/package.json +1 -1
- package/player.ts +14 -13
package/dist/player.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare class ContinuousPlayer extends EventEmitter {
|
|
|
10
10
|
playChunk(audioData: ArrayBuffer): void;
|
|
11
11
|
private performBufferOperation;
|
|
12
12
|
private appendNextChunk;
|
|
13
|
+
private removeBufferedRange;
|
|
13
14
|
private removeBuffer;
|
|
14
15
|
private resetTimestampOffset;
|
|
15
16
|
private abortBuffer;
|
package/dist/player.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
@@ -49,25 +58,29 @@ class ContinuousPlayer extends events_1.default {
|
|
|
49
58
|
});
|
|
50
59
|
}
|
|
51
60
|
appendNextChunk(chunk) {
|
|
52
|
-
console.log("appendNextChunk");
|
|
53
61
|
return this.performBufferOperation(() => {
|
|
54
62
|
if (!this.sourceBuffer)
|
|
55
63
|
return;
|
|
56
64
|
this.sourceBuffer.appendBuffer(chunk);
|
|
57
65
|
});
|
|
58
66
|
}
|
|
59
|
-
|
|
60
|
-
console.log("removeBuffer");
|
|
67
|
+
removeBufferedRange() {
|
|
61
68
|
return this.performBufferOperation(() => {
|
|
69
|
+
if (!this.sourceBuffer)
|
|
70
|
+
return;
|
|
71
|
+
this.sourceBuffer.remove(0, this.sourceBuffer.buffered.end(0));
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
removeBuffer() {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
76
|
if (!this.sourceBuffer)
|
|
63
77
|
return;
|
|
64
78
|
while (this.sourceBuffer.buffered.length > 0) {
|
|
65
|
-
|
|
79
|
+
yield this.removeBufferedRange();
|
|
66
80
|
}
|
|
67
81
|
});
|
|
68
82
|
}
|
|
69
83
|
resetTimestampOffset() {
|
|
70
|
-
console.log("resetTimestampOffset");
|
|
71
84
|
return this.performBufferOperation(() => {
|
|
72
85
|
if (!this.sourceBuffer)
|
|
73
86
|
return;
|
|
@@ -75,10 +88,10 @@ class ContinuousPlayer extends events_1.default {
|
|
|
75
88
|
});
|
|
76
89
|
}
|
|
77
90
|
abortBuffer() {
|
|
78
|
-
|
|
79
|
-
return this.performBufferOperation(() => {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
92
|
if (!this.sourceBuffer)
|
|
81
93
|
return;
|
|
94
|
+
// This does not emit updateend
|
|
82
95
|
this.sourceBuffer.abort();
|
|
83
96
|
});
|
|
84
97
|
}
|
package/package.json
CHANGED
package/player.ts
CHANGED
|
@@ -67,37 +67,38 @@ export class ContinuousPlayer extends EventEmitter {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
private appendNextChunk(chunk: ArrayBuffer) {
|
|
70
|
-
console.log("appendNextChunk");
|
|
71
70
|
return this.performBufferOperation(() => {
|
|
72
71
|
if (!this.sourceBuffer) return;
|
|
73
72
|
this.sourceBuffer.appendBuffer(chunk);
|
|
74
73
|
});
|
|
75
74
|
}
|
|
76
75
|
|
|
77
|
-
private
|
|
78
|
-
console.log("removeBuffer");
|
|
76
|
+
private removeBufferedRange() {
|
|
79
77
|
return this.performBufferOperation(() => {
|
|
80
78
|
if (!this.sourceBuffer) return;
|
|
81
|
-
|
|
82
|
-
this.sourceBuffer.remove(0, this.sourceBuffer.buffered.end(0));
|
|
83
|
-
}
|
|
79
|
+
this.sourceBuffer.remove(0, this.sourceBuffer.buffered.end(0));
|
|
84
80
|
});
|
|
85
81
|
}
|
|
86
82
|
|
|
83
|
+
private async removeBuffer() {
|
|
84
|
+
if (!this.sourceBuffer) return;
|
|
85
|
+
|
|
86
|
+
while (this.sourceBuffer.buffered.length > 0) {
|
|
87
|
+
await this.removeBufferedRange();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
87
91
|
private resetTimestampOffset() {
|
|
88
|
-
console.log("resetTimestampOffset");
|
|
89
92
|
return this.performBufferOperation(() => {
|
|
90
93
|
if (!this.sourceBuffer) return;
|
|
91
94
|
this.sourceBuffer.timestampOffset = 0;
|
|
92
95
|
});
|
|
93
96
|
}
|
|
94
97
|
|
|
95
|
-
private abortBuffer() {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
this.sourceBuffer.abort();
|
|
100
|
-
});
|
|
98
|
+
private async abortBuffer() {
|
|
99
|
+
if (!this.sourceBuffer) return;
|
|
100
|
+
// This does not emit updateend
|
|
101
|
+
this.sourceBuffer.abort();
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
clear() {
|