@gjsify/webaudio 0.3.12 → 0.3.14
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/lib/esm/audio-buffer-source-node.js +60 -58
- package/lib/esm/audio-buffer.js +37 -36
- package/lib/esm/audio-context.js +88 -89
- package/lib/esm/audio-destination-node.js +10 -8
- package/lib/esm/audio-node.js +33 -32
- package/lib/esm/audio-param.js +78 -76
- package/lib/esm/gain-node.js +18 -16
- package/lib/esm/gst-decoder.js +71 -62
- package/lib/esm/gst-init.js +9 -8
- package/lib/esm/gst-player.js +121 -124
- package/lib/esm/html-audio-element.js +59 -59
- package/lib/esm/index.js +7 -15
- package/lib/esm/register.js +11 -5
- package/package.json +10 -10
package/lib/esm/gain-node.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { AudioNode } from "./audio-node.js";
|
|
2
2
|
import { AudioParam } from "./audio-param.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
GainNode
|
|
3
|
+
|
|
4
|
+
//#region src/gain-node.ts
|
|
5
|
+
var GainNode = class extends AudioNode {
|
|
6
|
+
gain;
|
|
7
|
+
/** @internal active players that need volume updates */
|
|
8
|
+
_activePlayers = new Set();
|
|
9
|
+
constructor() {
|
|
10
|
+
super(1, 1);
|
|
11
|
+
this.gain = new AudioParam(1, 0, 10);
|
|
12
|
+
this.gain._onChange = (value) => {
|
|
13
|
+
for (const player of this._activePlayers) {
|
|
14
|
+
player.setVolume(value);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
19
18
|
};
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { GainNode };
|
package/lib/esm/gst-decoder.js
CHANGED
|
@@ -1,67 +1,76 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Gst, ensureGstInit } from "./gst-init.js";
|
|
2
2
|
import { AudioBuffer } from "./audio-buffer.js";
|
|
3
3
|
import GstApp from "gi://GstApp?version=1.0";
|
|
4
|
+
|
|
5
|
+
//#region src/gst-decoder.ts
|
|
4
6
|
void GstApp;
|
|
5
|
-
const PIPELINE_DESC = "appsrc name=src ! decodebin ! audioconvert ! audioresample ! capsfilter caps=audio/x-raw,format=F32LE,layout=interleaved ! appsink name=sink sync=false";
|
|
7
|
+
const PIPELINE_DESC = "appsrc name=src ! decodebin ! audioconvert ! audioresample ! " + "capsfilter caps=audio/x-raw,format=F32LE,layout=interleaved ! " + "appsink name=sink sync=false";
|
|
8
|
+
/**
|
|
9
|
+
* Decode encoded audio data (MP3, WAV, OGG, FLAC, etc.) into an AudioBuffer
|
|
10
|
+
* containing PCM Float32 channel data.
|
|
11
|
+
*
|
|
12
|
+
* This is a synchronous operation that blocks until decoding completes.
|
|
13
|
+
* It must be called from the main thread (GJS requirement).
|
|
14
|
+
*/
|
|
6
15
|
function decodeAudioDataSync(arrayBuffer) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
16
|
+
ensureGstInit();
|
|
17
|
+
if (!(arrayBuffer instanceof ArrayBuffer) || arrayBuffer.byteLength === 0) {
|
|
18
|
+
throw new DOMException("Unable to decode audio data", "EncodingError");
|
|
19
|
+
}
|
|
20
|
+
const pipeline = Gst.parse_launch(PIPELINE_DESC);
|
|
21
|
+
const appsrc = pipeline.get_by_name("src");
|
|
22
|
+
const appsink = pipeline.get_by_name("sink");
|
|
23
|
+
pipeline.set_state(Gst.State.PLAYING);
|
|
24
|
+
const data = new Uint8Array(arrayBuffer);
|
|
25
|
+
appsrc.push_buffer(Gst.Buffer.new_wrapped(data));
|
|
26
|
+
appsrc.end_of_stream();
|
|
27
|
+
const chunks = [];
|
|
28
|
+
let sampleRate = 0;
|
|
29
|
+
let channels = 0;
|
|
30
|
+
while (true) {
|
|
31
|
+
const sample = appsink.try_pull_sample(2 * Number(Gst.SECOND));
|
|
32
|
+
if (!sample) break;
|
|
33
|
+
if (sampleRate === 0) {
|
|
34
|
+
const caps = sample.get_caps();
|
|
35
|
+
if (caps) {
|
|
36
|
+
const struct = caps.get_structure(0);
|
|
37
|
+
[, sampleRate] = struct.get_int("rate");
|
|
38
|
+
[, channels] = struct.get_int("channels");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const buffer = sample.get_buffer();
|
|
42
|
+
if (!buffer) continue;
|
|
43
|
+
const [ok, mapInfo] = buffer.map(Gst.MapFlags.READ);
|
|
44
|
+
if (ok) {
|
|
45
|
+
chunks.push(new Uint8Array(mapInfo.data));
|
|
46
|
+
buffer.unmap(mapInfo);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
pipeline.set_state(Gst.State.NULL);
|
|
50
|
+
if (sampleRate === 0 || channels === 0) {
|
|
51
|
+
throw new DOMException("Unable to decode audio data", "EncodingError");
|
|
52
|
+
}
|
|
53
|
+
let totalBytes = 0;
|
|
54
|
+
for (const c of chunks) totalBytes += c.length;
|
|
55
|
+
const totalFrames = totalBytes / (4 * channels);
|
|
56
|
+
const audioBuffer = new AudioBuffer({
|
|
57
|
+
numberOfChannels: channels,
|
|
58
|
+
length: totalFrames,
|
|
59
|
+
sampleRate
|
|
60
|
+
});
|
|
61
|
+
let offset = 0;
|
|
62
|
+
for (const chunk of chunks) {
|
|
63
|
+
const f32 = new Float32Array(chunk.buffer, chunk.byteOffset, chunk.length / 4);
|
|
64
|
+
const framesInChunk = f32.length / channels;
|
|
65
|
+
for (let frame = 0; frame < framesInChunk; frame++) {
|
|
66
|
+
for (let ch = 0; ch < channels; ch++) {
|
|
67
|
+
audioBuffer._channelData[ch][offset + frame] = f32[frame * channels + ch];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
offset += framesInChunk;
|
|
71
|
+
}
|
|
72
|
+
return audioBuffer;
|
|
64
73
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
};
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
export { decodeAudioDataSync };
|
package/lib/esm/gst-init.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import Gst from "gi://Gst?version=1.0";
|
|
2
|
+
|
|
3
|
+
//#region src/gst-init.ts
|
|
2
4
|
let initialized = false;
|
|
3
5
|
function ensureGstInit() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
if (!initialized) {
|
|
7
|
+
Gst.init(null);
|
|
8
|
+
initialized = true;
|
|
9
|
+
}
|
|
8
10
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { Gst, ensureGstInit };
|
package/lib/esm/gst-player.js
CHANGED
|
@@ -1,128 +1,125 @@
|
|
|
1
|
+
import { Gst, ensureGstInit } from "./gst-init.js";
|
|
1
2
|
import GLib from "gi://GLib?version=2.0";
|
|
2
|
-
import { ensureGstInit, Gst } from "./gst-init.js";
|
|
3
3
|
import GstApp from "gi://GstApp?version=1.0";
|
|
4
|
+
|
|
5
|
+
//#region src/gst-player.ts
|
|
4
6
|
void GstApp;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
interleaved[frame * ch + c] = buf._channelData[c][startFrame + frame];
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return new Uint8Array(interleaved.buffer);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
export {
|
|
127
|
-
GstPlayer
|
|
7
|
+
/**
|
|
8
|
+
* Manages a single GStreamer playback pipeline for one AudioBufferSourceNode.start() call.
|
|
9
|
+
*/
|
|
10
|
+
var GstPlayer = class {
|
|
11
|
+
_pipeline = null;
|
|
12
|
+
_volumeElement = null;
|
|
13
|
+
_busWatchId = null;
|
|
14
|
+
_ended = false;
|
|
15
|
+
_loop;
|
|
16
|
+
_onEnded;
|
|
17
|
+
_audioBuffer;
|
|
18
|
+
constructor(options) {
|
|
19
|
+
ensureGstInit();
|
|
20
|
+
this._loop = options.loop;
|
|
21
|
+
this._onEnded = options.onEnded;
|
|
22
|
+
this._audioBuffer = options.audioBuffer;
|
|
23
|
+
const { audioBuffer, volume, offset, duration, playbackRate } = options;
|
|
24
|
+
const sr = audioBuffer.sampleRate;
|
|
25
|
+
const ch = audioBuffer.numberOfChannels;
|
|
26
|
+
const pcmData = this._interleave(audioBuffer, offset, duration);
|
|
27
|
+
if (pcmData.length === 0) {
|
|
28
|
+
this._fireEnded();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const capsStr = `audio/x-raw,format=F32LE,rate=${sr},channels=${ch},layout=interleaved`;
|
|
32
|
+
const desc = `appsrc name=src caps="${capsStr}" format=3 ! audioconvert ! volume name=vol ! autoaudiosink`;
|
|
33
|
+
this._pipeline = Gst.parse_launch(desc);
|
|
34
|
+
this._volumeElement = this._pipeline.get_by_name("vol");
|
|
35
|
+
const appsrc = this._pipeline.get_by_name("src");
|
|
36
|
+
this._volumeElement.set_property("volume", Math.max(0, Math.min(volume, 10)));
|
|
37
|
+
const bus = this._pipeline.get_bus();
|
|
38
|
+
this._busWatchId = bus.add_watch(0, (_bus, msg) => {
|
|
39
|
+
if (msg.type === Gst.MessageType.EOS) {
|
|
40
|
+
if (this._loop && !this._ended) {
|
|
41
|
+
this._restartPlayback(appsrc, pcmData);
|
|
42
|
+
} else {
|
|
43
|
+
this._fireEnded();
|
|
44
|
+
}
|
|
45
|
+
} else if (msg.type === Gst.MessageType.ERROR) {
|
|
46
|
+
this._fireEnded();
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
});
|
|
50
|
+
const gstBuf = Gst.Buffer.new_wrapped(pcmData);
|
|
51
|
+
const totalFrames = pcmData.length / (4 * ch);
|
|
52
|
+
gstBuf.pts = 0;
|
|
53
|
+
gstBuf.duration = Math.floor(totalFrames / sr * Number(Gst.SECOND));
|
|
54
|
+
appsrc.push_buffer(gstBuf);
|
|
55
|
+
appsrc.end_of_stream();
|
|
56
|
+
if (playbackRate !== 1) {
|
|
57
|
+
this._pipeline.set_state(Gst.State.PAUSED);
|
|
58
|
+
this._pipeline.seek(playbackRate, Gst.Format.TIME, Gst.SeekFlags.FLUSH | Gst.SeekFlags.ACCURATE, Gst.SeekType.SET, 0, Gst.SeekType.NONE, -1);
|
|
59
|
+
}
|
|
60
|
+
this._pipeline.set_state(Gst.State.PLAYING);
|
|
61
|
+
}
|
|
62
|
+
/** Update volume on a running pipeline */
|
|
63
|
+
setVolume(value) {
|
|
64
|
+
if (this._volumeElement && !this._ended) {
|
|
65
|
+
this._volumeElement.set_property("volume", Math.max(0, Math.min(value, 10)));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** Update loop flag */
|
|
69
|
+
setLoop(value) {
|
|
70
|
+
this._loop = value;
|
|
71
|
+
}
|
|
72
|
+
/** Stop playback and clean up */
|
|
73
|
+
stop() {
|
|
74
|
+
if (this._ended) return;
|
|
75
|
+
this._fireEnded();
|
|
76
|
+
}
|
|
77
|
+
/** Whether playback has ended */
|
|
78
|
+
get ended() {
|
|
79
|
+
return this._ended;
|
|
80
|
+
}
|
|
81
|
+
_restartPlayback(appsrc, pcmData) {
|
|
82
|
+
if (this._pipeline) {
|
|
83
|
+
this._pipeline.seek_simple(Gst.Format.TIME, Gst.SeekFlags.FLUSH, 0);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
_fireEnded() {
|
|
87
|
+
if (this._ended) return;
|
|
88
|
+
this._ended = true;
|
|
89
|
+
this._cleanup();
|
|
90
|
+
this._onEnded();
|
|
91
|
+
}
|
|
92
|
+
_cleanup() {
|
|
93
|
+
const pipeline = this._pipeline;
|
|
94
|
+
this._pipeline = null;
|
|
95
|
+
this._volumeElement = null;
|
|
96
|
+
this._busWatchId = null;
|
|
97
|
+
if (pipeline) {
|
|
98
|
+
GLib.idle_add(GLib.PRIORITY_LOW, () => {
|
|
99
|
+
pipeline.set_state(Gst.State.NULL);
|
|
100
|
+
return GLib.SOURCE_REMOVE;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Interleave AudioBuffer's per-channel Float32Arrays into a single Uint8Array.
|
|
106
|
+
* Applies offset (seconds) and optional duration (seconds).
|
|
107
|
+
*/
|
|
108
|
+
_interleave(buf, offsetSec, durationSec) {
|
|
109
|
+
const ch = buf.numberOfChannels;
|
|
110
|
+
const startFrame = Math.min(Math.floor(offsetSec * buf.sampleRate), buf.length);
|
|
111
|
+
const maxFrames = buf.length - startFrame;
|
|
112
|
+
const frames = durationSec !== undefined ? Math.min(Math.floor(durationSec * buf.sampleRate), maxFrames) : maxFrames;
|
|
113
|
+
if (frames <= 0) return new Uint8Array(0);
|
|
114
|
+
const interleaved = new Float32Array(frames * ch);
|
|
115
|
+
for (let frame = 0; frame < frames; frame++) {
|
|
116
|
+
for (let c = 0; c < ch; c++) {
|
|
117
|
+
interleaved[frame * ch + c] = buf._channelData[c][startFrame + frame];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return new Uint8Array(interleaved.buffer);
|
|
121
|
+
}
|
|
128
122
|
};
|
|
123
|
+
|
|
124
|
+
//#endregion
|
|
125
|
+
export { GstPlayer };
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { Gst, ensureGstInit } from "./gst-init.js";
|
|
2
|
+
|
|
3
|
+
//#region src/html-audio-element.ts
|
|
4
|
+
const SUPPORTED_TYPES = new Set([
|
|
5
|
+
"audio/mpeg",
|
|
6
|
+
"audio/mp3",
|
|
7
|
+
"audio/wav",
|
|
8
|
+
"audio/x-wav",
|
|
9
|
+
"audio/ogg",
|
|
10
|
+
"audio/webm",
|
|
11
|
+
"audio/flac",
|
|
12
|
+
"audio/x-flac",
|
|
13
|
+
"audio/aac",
|
|
14
|
+
"audio/mp4"
|
|
13
15
|
]);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
export {
|
|
60
|
-
HTMLAudioElement
|
|
16
|
+
var HTMLAudioElement = class {
|
|
17
|
+
src = "";
|
|
18
|
+
volume = 1;
|
|
19
|
+
loop = false;
|
|
20
|
+
paused = true;
|
|
21
|
+
currentTime = 0;
|
|
22
|
+
duration = 0;
|
|
23
|
+
readyState = 0;
|
|
24
|
+
_pipeline = null;
|
|
25
|
+
canPlayType(type) {
|
|
26
|
+
const mime = type.split(";")[0].trim().toLowerCase();
|
|
27
|
+
return SUPPORTED_TYPES.has(mime) ? "maybe" : "";
|
|
28
|
+
}
|
|
29
|
+
play() {
|
|
30
|
+
if (!this.src) return Promise.resolve();
|
|
31
|
+
ensureGstInit();
|
|
32
|
+
this._cleanup();
|
|
33
|
+
this._pipeline = Gst.ElementFactory.make("playbin", "player");
|
|
34
|
+
if (!this._pipeline) return Promise.resolve();
|
|
35
|
+
this._pipeline.set_property("uri", this.src);
|
|
36
|
+
this._pipeline.set_property("volume", this.volume);
|
|
37
|
+
this._pipeline.set_state(Gst.State.PLAYING);
|
|
38
|
+
this.paused = false;
|
|
39
|
+
return Promise.resolve();
|
|
40
|
+
}
|
|
41
|
+
pause() {
|
|
42
|
+
if (this._pipeline) {
|
|
43
|
+
this._pipeline.set_state(Gst.State.PAUSED);
|
|
44
|
+
this.paused = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
load() {
|
|
48
|
+
this._cleanup();
|
|
49
|
+
}
|
|
50
|
+
addEventListener(_type, _listener) {}
|
|
51
|
+
removeEventListener(_type, _listener) {}
|
|
52
|
+
_cleanup() {
|
|
53
|
+
if (this._pipeline) {
|
|
54
|
+
this._pipeline.set_state(Gst.State.NULL);
|
|
55
|
+
this._pipeline = null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
61
58
|
};
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
export { HTMLAudioElement };
|
package/lib/esm/index.js
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
import { AudioContext } from "./audio-context.js";
|
|
2
|
-
import { AudioBuffer } from "./audio-buffer.js";
|
|
3
1
|
import { AudioNode } from "./audio-node.js";
|
|
4
|
-
import { AudioDestinationNode } from "./audio-destination-node.js";
|
|
5
|
-
import { AudioBufferSourceNode } from "./audio-buffer-source-node.js";
|
|
6
|
-
import { GainNode } from "./gain-node.js";
|
|
7
2
|
import { AudioParam } from "./audio-param.js";
|
|
3
|
+
import { GainNode } from "./gain-node.js";
|
|
4
|
+
import { AudioBufferSourceNode } from "./audio-buffer-source-node.js";
|
|
5
|
+
import { AudioBuffer } from "./audio-buffer.js";
|
|
6
|
+
import { AudioDestinationNode } from "./audio-destination-node.js";
|
|
7
|
+
import { AudioContext } from "./audio-context.js";
|
|
8
8
|
import { HTMLAudioElement } from "./html-audio-element.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
AudioBufferSourceNode,
|
|
12
|
-
AudioContext,
|
|
13
|
-
AudioDestinationNode,
|
|
14
|
-
AudioNode,
|
|
15
|
-
AudioParam,
|
|
16
|
-
GainNode,
|
|
17
|
-
HTMLAudioElement
|
|
18
|
-
};
|
|
9
|
+
|
|
10
|
+
export { AudioBuffer, AudioBufferSourceNode, AudioContext, AudioDestinationNode, AudioNode, AudioParam, GainNode, HTMLAudioElement };
|
package/lib/esm/register.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import { AudioContext
|
|
1
|
+
import { AudioContext } from "./audio-context.js";
|
|
2
|
+
import { HTMLAudioElement } from "./html-audio-element.js";
|
|
3
|
+
import "./index.js";
|
|
4
|
+
|
|
5
|
+
//#region src/register.ts
|
|
2
6
|
if (typeof globalThis.AudioContext === "undefined") {
|
|
3
|
-
|
|
7
|
+
globalThis.AudioContext = AudioContext;
|
|
4
8
|
}
|
|
5
9
|
if (typeof globalThis.webkitAudioContext === "undefined") {
|
|
6
|
-
|
|
10
|
+
globalThis.webkitAudioContext = AudioContext;
|
|
7
11
|
}
|
|
8
12
|
if (typeof globalThis.Audio === "undefined") {
|
|
9
|
-
|
|
13
|
+
globalThis.Audio = HTMLAudioElement;
|
|
10
14
|
}
|
|
11
15
|
if (typeof globalThis.HTMLAudioElement === "undefined") {
|
|
12
|
-
|
|
16
|
+
globalThis.HTMLAudioElement = HTMLAudioElement;
|
|
13
17
|
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|