@94ai/nf-audio 8.3.15 → 8.3.17
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/nf-audio.cjs.js +7 -25
- package/lib/nf-audio.esm-bundler.js +7 -25
- package/package/nf-audio.vue +6 -24
- package/package.json +4 -4
package/lib/nf-audio.cjs.js
CHANGED
|
@@ -296,33 +296,15 @@ const _sfc_main = {
|
|
|
296
296
|
return window.location.protocol === "https:" || window.location.hostname === "localhost";
|
|
297
297
|
},
|
|
298
298
|
async startAudioCtx() {
|
|
299
|
-
var _a, _b
|
|
299
|
+
var _a, _b;
|
|
300
300
|
if (this.isHighPrecision()) {
|
|
301
301
|
try {
|
|
302
302
|
if (!this.audioCtx) {
|
|
303
|
-
|
|
304
|
-
this.audioCtx = new AudioCtx();
|
|
305
|
-
if (this.audioCtx.state === "suspended") {
|
|
306
|
-
await this.audioCtx.resume();
|
|
307
|
-
}
|
|
303
|
+
this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
|
308
304
|
this.audioSource = this.audioCtx.createMediaElementSource(this.audio);
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
const workletUrl = URL.createObjectURL(blob);
|
|
313
|
-
try {
|
|
314
|
-
await ((_a = this.audioCtx.audioWorklet) == null ? void 0 : _a.addModule(workletUrl));
|
|
315
|
-
this.processor = new AudioWorkletNode(this.audioCtx, "tick");
|
|
316
|
-
this.audioSource.connect(this.processor).connect(this.audioCtx.destination);
|
|
317
|
-
} catch (workletErr) {
|
|
318
|
-
if (this.debuglog) {
|
|
319
|
-
console.warn("AudioWorklet unavailable, falling back to direct output:", workletErr);
|
|
320
|
-
}
|
|
321
|
-
this.audioSource.connect(this.audioCtx.destination);
|
|
322
|
-
this.processor = null;
|
|
323
|
-
} finally {
|
|
324
|
-
URL.revokeObjectURL(workletUrl);
|
|
325
|
-
}
|
|
305
|
+
await ((_a = this.audioCtx.audioWorklet) == null ? void 0 : _a.addModule("data:application/javascript," + encodeURIComponent(this.audioWorkletProcessor)));
|
|
306
|
+
this.processor = new AudioWorkletNode(this.audioCtx, "tick");
|
|
307
|
+
this.audioSource.connect(this.processor).connect(this.audioCtx.destination);
|
|
326
308
|
if ((_b = this.processor) == null ? void 0 : _b.port) {
|
|
327
309
|
this.processor.port.onmessage = (event) => {
|
|
328
310
|
if (event.data.command === "tick") {
|
|
@@ -340,12 +322,12 @@ const _sfc_main = {
|
|
|
340
322
|
};
|
|
341
323
|
}
|
|
342
324
|
} else {
|
|
343
|
-
|
|
325
|
+
this.audioCtx.resume();
|
|
344
326
|
}
|
|
345
327
|
} catch (e) {
|
|
346
328
|
console.log(e);
|
|
347
329
|
}
|
|
348
|
-
|
|
330
|
+
this.processor.port.postMessage({
|
|
349
331
|
command: "start"
|
|
350
332
|
});
|
|
351
333
|
}
|
|
@@ -294,33 +294,15 @@ const _sfc_main = {
|
|
|
294
294
|
return window.location.protocol === "https:" || window.location.hostname === "localhost";
|
|
295
295
|
},
|
|
296
296
|
async startAudioCtx() {
|
|
297
|
-
var _a, _b
|
|
297
|
+
var _a, _b;
|
|
298
298
|
if (this.isHighPrecision()) {
|
|
299
299
|
try {
|
|
300
300
|
if (!this.audioCtx) {
|
|
301
|
-
|
|
302
|
-
this.audioCtx = new AudioCtx();
|
|
303
|
-
if (this.audioCtx.state === "suspended") {
|
|
304
|
-
await this.audioCtx.resume();
|
|
305
|
-
}
|
|
301
|
+
this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
|
306
302
|
this.audioSource = this.audioCtx.createMediaElementSource(this.audio);
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
const workletUrl = URL.createObjectURL(blob);
|
|
311
|
-
try {
|
|
312
|
-
await ((_a = this.audioCtx.audioWorklet) == null ? void 0 : _a.addModule(workletUrl));
|
|
313
|
-
this.processor = new AudioWorkletNode(this.audioCtx, "tick");
|
|
314
|
-
this.audioSource.connect(this.processor).connect(this.audioCtx.destination);
|
|
315
|
-
} catch (workletErr) {
|
|
316
|
-
if (this.debuglog) {
|
|
317
|
-
console.warn("AudioWorklet unavailable, falling back to direct output:", workletErr);
|
|
318
|
-
}
|
|
319
|
-
this.audioSource.connect(this.audioCtx.destination);
|
|
320
|
-
this.processor = null;
|
|
321
|
-
} finally {
|
|
322
|
-
URL.revokeObjectURL(workletUrl);
|
|
323
|
-
}
|
|
303
|
+
await ((_a = this.audioCtx.audioWorklet) == null ? void 0 : _a.addModule("data:application/javascript," + encodeURIComponent(this.audioWorkletProcessor)));
|
|
304
|
+
this.processor = new AudioWorkletNode(this.audioCtx, "tick");
|
|
305
|
+
this.audioSource.connect(this.processor).connect(this.audioCtx.destination);
|
|
324
306
|
if ((_b = this.processor) == null ? void 0 : _b.port) {
|
|
325
307
|
this.processor.port.onmessage = (event) => {
|
|
326
308
|
if (event.data.command === "tick") {
|
|
@@ -338,12 +320,12 @@ const _sfc_main = {
|
|
|
338
320
|
};
|
|
339
321
|
}
|
|
340
322
|
} else {
|
|
341
|
-
|
|
323
|
+
this.audioCtx.resume();
|
|
342
324
|
}
|
|
343
325
|
} catch (e) {
|
|
344
326
|
console.log(e);
|
|
345
327
|
}
|
|
346
|
-
|
|
328
|
+
this.processor.port.postMessage({
|
|
347
329
|
command: "start"
|
|
348
330
|
});
|
|
349
331
|
}
|
package/package/nf-audio.vue
CHANGED
|
@@ -484,29 +484,11 @@ export default {
|
|
|
484
484
|
if (this.isHighPrecision()) {
|
|
485
485
|
try {
|
|
486
486
|
if (!this.audioCtx) {
|
|
487
|
-
|
|
488
|
-
this.audioCtx = new AudioCtx()
|
|
489
|
-
if (this.audioCtx.state === 'suspended') {
|
|
490
|
-
await this.audioCtx.resume()
|
|
491
|
-
}
|
|
487
|
+
this.audioCtx = new (window.AudioContext || window.webkitAudioContext)()
|
|
492
488
|
this.audioSource = this.audioCtx.createMediaElementSource(this.audio)
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
try {
|
|
497
|
-
await this.audioCtx.audioWorklet?.addModule(workletUrl)
|
|
498
|
-
this.processor = new AudioWorkletNode(this.audioCtx, 'tick')
|
|
499
|
-
this.audioSource.connect(this.processor).connect(this.audioCtx.destination)
|
|
500
|
-
} catch (workletErr) {
|
|
501
|
-
if (this.debuglog) {
|
|
502
|
-
console.warn('AudioWorklet unavailable, falling back to direct output:', workletErr)
|
|
503
|
-
}
|
|
504
|
-
// AudioWorklet 不可用时,直接连接到 destination,保证有声音
|
|
505
|
-
this.audioSource.connect(this.audioCtx.destination)
|
|
506
|
-
this.processor = null
|
|
507
|
-
} finally {
|
|
508
|
-
URL.revokeObjectURL(workletUrl)
|
|
509
|
-
}
|
|
489
|
+
await this.audioCtx.audioWorklet?.addModule('data:application/javascript,' + encodeURIComponent(this.audioWorkletProcessor))
|
|
490
|
+
this.processor = new AudioWorkletNode(this.audioCtx, 'tick')
|
|
491
|
+
this.audioSource.connect(this.processor).connect(this.audioCtx.destination)
|
|
510
492
|
if (this.processor?.port) {
|
|
511
493
|
this.processor.port.onmessage = (event) => {
|
|
512
494
|
if (event.data.command === 'tick') {
|
|
@@ -524,12 +506,12 @@ export default {
|
|
|
524
506
|
}
|
|
525
507
|
}
|
|
526
508
|
} else {
|
|
527
|
-
|
|
509
|
+
this.audioCtx.resume()
|
|
528
510
|
}
|
|
529
511
|
} catch (e) {
|
|
530
512
|
console.log(e)
|
|
531
513
|
}
|
|
532
|
-
this.processor
|
|
514
|
+
this.processor.port.postMessage({ command: 'start' })
|
|
533
515
|
}
|
|
534
516
|
},
|
|
535
517
|
pause() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@94ai/nf-audio",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.17",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "liuxiangxiang <liuxiangxiang@94ai.com>",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"url": "http://94ai.gitlab.com/zoujiahe/common-ui.git"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@94ai/nf-message": "^8.3.
|
|
18
|
-
"@94ai/nf-theme-chalk": "^8.3.
|
|
17
|
+
"@94ai/nf-message": "^8.3.17",
|
|
18
|
+
"@94ai/nf-theme-chalk": "^8.3.17",
|
|
19
19
|
"vue-demi": "^0.14.5"
|
|
20
20
|
},
|
|
21
21
|
"peerDependenciesMeta": {
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"types": "lib/index.d.ts",
|
|
32
32
|
"main": "lib/nf-audio.cjs.js",
|
|
33
33
|
"module": "lib/nf-audio.esm-bundler.js",
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "73c9cbd0da85443cbd495c812a282676a1fa08cb"
|
|
35
35
|
}
|