@vapi-ai/web 1.0.134 → 1.0.136
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/AtomicMediaSource.ts
CHANGED
|
@@ -16,10 +16,12 @@ function getMediaSource() {
|
|
|
16
16
|
if (window.MediaSource) {
|
|
17
17
|
return new window.MediaSource();
|
|
18
18
|
}
|
|
19
|
+
|
|
20
|
+
return null;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
class AtomicMediaSource extends EventEmitter {
|
|
22
|
-
mediaSource:
|
|
24
|
+
mediaSource: any;
|
|
23
25
|
sourceBuffer: SourceBuffer | null = null;
|
|
24
26
|
private operationsQueue: QueueObject<() => Promise<void>>;
|
|
25
27
|
|
|
@@ -28,12 +30,20 @@ class AtomicMediaSource extends EventEmitter {
|
|
|
28
30
|
this.mediaSource = getMediaSource();
|
|
29
31
|
this.operationsQueue = this.createOperationQueue();
|
|
30
32
|
|
|
33
|
+
if (!this.mediaSource) {
|
|
34
|
+
console.error("MediaSource is not supported in your browser.");
|
|
35
|
+
// Display a message to the user, or handle this situation in another way
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
31
39
|
this.mediaSource.addEventListener("sourceopen", () => {
|
|
32
40
|
this.mediaSource.duration = Number.POSITIVE_INFINITY;
|
|
33
41
|
this.sourceBuffer = this.mediaSource.addSourceBuffer(
|
|
34
42
|
'audio/webm; codecs="opus"'
|
|
35
43
|
);
|
|
36
|
-
this.sourceBuffer
|
|
44
|
+
if (this.sourceBuffer) {
|
|
45
|
+
this.sourceBuffer.mode = "sequence";
|
|
46
|
+
}
|
|
37
47
|
});
|
|
38
48
|
}
|
|
39
49
|
|
|
@@ -13,6 +13,7 @@ function getMediaSource() {
|
|
|
13
13
|
if (window.MediaSource) {
|
|
14
14
|
return new window.MediaSource();
|
|
15
15
|
}
|
|
16
|
+
return null;
|
|
16
17
|
}
|
|
17
18
|
class AtomicMediaSource extends events_1.default {
|
|
18
19
|
constructor() {
|
|
@@ -20,10 +21,17 @@ class AtomicMediaSource extends events_1.default {
|
|
|
20
21
|
this.sourceBuffer = null;
|
|
21
22
|
this.mediaSource = getMediaSource();
|
|
22
23
|
this.operationsQueue = this.createOperationQueue();
|
|
24
|
+
if (!this.mediaSource) {
|
|
25
|
+
console.error("MediaSource is not supported in your browser.");
|
|
26
|
+
// Display a message to the user, or handle this situation in another way
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
23
29
|
this.mediaSource.addEventListener("sourceopen", () => {
|
|
24
30
|
this.mediaSource.duration = Number.POSITIVE_INFINITY;
|
|
25
31
|
this.sourceBuffer = this.mediaSource.addSourceBuffer('audio/webm; codecs="opus"');
|
|
26
|
-
this.sourceBuffer
|
|
32
|
+
if (this.sourceBuffer) {
|
|
33
|
+
this.sourceBuffer.mode = "sequence";
|
|
34
|
+
}
|
|
27
35
|
});
|
|
28
36
|
}
|
|
29
37
|
appendBuffer(buffer) {
|