@94ai/nf-audio 3.3.65 → 3.3.67
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 +38 -24
- package/lib/nf-audio.esm-bundler.js +38 -24
- package/package/nf-audio.vue +37 -24
- package/package.json +3 -3
package/lib/nf-audio.cjs.js
CHANGED
|
@@ -285,29 +285,36 @@ const _sfc_main = {
|
|
|
285
285
|
return window.location.protocol === "https:" || window.location.hostname === "localhost";
|
|
286
286
|
},
|
|
287
287
|
async startAudioCtx() {
|
|
288
|
+
var _a, _b;
|
|
288
289
|
if (this.isHighPrecision()) {
|
|
289
|
-
|
|
290
|
-
this.audioCtx
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
if (
|
|
297
|
-
|
|
298
|
-
if (
|
|
299
|
-
if (this.
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
290
|
+
try {
|
|
291
|
+
if (!this.audioCtx) {
|
|
292
|
+
this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
|
293
|
+
this.audioSource = this.audioCtx.createMediaElementSource(this.audio);
|
|
294
|
+
await ((_a = this.audioCtx.audioWorklet) == null ? void 0 : _a.addModule("data:application/javascript," + encodeURIComponent(this.audioWorkletProcessor)));
|
|
295
|
+
this.processor = new AudioWorkletNode(this.audioCtx, "tick");
|
|
296
|
+
this.audioSource.connect(this.processor).connect(this.audioCtx.destination);
|
|
297
|
+
if ((_b = this.processor) == null ? void 0 : _b.port) {
|
|
298
|
+
this.processor.port.onmessage = (event) => {
|
|
299
|
+
if (event.data.command === "tick") {
|
|
300
|
+
if (this.betweenPlaying) {
|
|
301
|
+
if (this.betweenEnd) {
|
|
302
|
+
if (this.debuglog) {
|
|
303
|
+
console.log(this.audio.currentTime);
|
|
304
|
+
}
|
|
305
|
+
if (this.audio.currentTime >= this.betweenEnd) {
|
|
306
|
+
this.pause();
|
|
307
|
+
}
|
|
308
|
+
}
|
|
304
309
|
}
|
|
305
310
|
}
|
|
306
|
-
}
|
|
311
|
+
};
|
|
307
312
|
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
|
|
313
|
+
} else {
|
|
314
|
+
this.audioCtx.resume();
|
|
315
|
+
}
|
|
316
|
+
} catch (e) {
|
|
317
|
+
console.log(e);
|
|
311
318
|
}
|
|
312
319
|
this.processor.port.postMessage({
|
|
313
320
|
command: "start"
|
|
@@ -333,10 +340,14 @@ const _sfc_main = {
|
|
|
333
340
|
await this.startAudioCtx();
|
|
334
341
|
this.audio.play();
|
|
335
342
|
},
|
|
343
|
+
loadError(e) {
|
|
344
|
+
this.$emit("error", e);
|
|
345
|
+
},
|
|
336
346
|
//视频在可以播放时触发
|
|
337
347
|
getDuration() {
|
|
338
348
|
this.totalTime = timeFormat(this.audio.duration);
|
|
339
349
|
this.audio.volume = this.volume;
|
|
350
|
+
this.$emit("canPlay", this.totalTime);
|
|
340
351
|
},
|
|
341
352
|
//进度条发生变化时触发
|
|
342
353
|
updateTime() {
|
|
@@ -362,7 +373,7 @@ const _sfc_main = {
|
|
|
362
373
|
},
|
|
363
374
|
betweenPlay() {
|
|
364
375
|
if (!this.disabled) {
|
|
365
|
-
if (this.audio.duration === 0) {
|
|
376
|
+
if (this.audio.duration === 0 || Number.isNaN(this.audio.duration)) {
|
|
366
377
|
nfMessage.Message.warning(this.unloadTip);
|
|
367
378
|
this.paused = true;
|
|
368
379
|
this.betweenPlaying = false;
|
|
@@ -380,8 +391,10 @@ const _sfc_main = {
|
|
|
380
391
|
//点击进度条更新进度
|
|
381
392
|
clickProgress(e) {
|
|
382
393
|
if (!this.disabled) {
|
|
383
|
-
if (this.audio.duration === 0) {
|
|
384
|
-
|
|
394
|
+
if (this.audio.duration === 0 || Number.isNaN(this.audio.duration)) {
|
|
395
|
+
if (!this.paused) {
|
|
396
|
+
nfMessage.Message.warning(this.unloadTip);
|
|
397
|
+
}
|
|
385
398
|
this.paused = true;
|
|
386
399
|
this.betweenPlaying = false;
|
|
387
400
|
return false;
|
|
@@ -400,7 +413,7 @@ const _sfc_main = {
|
|
|
400
413
|
//鼠标弹起
|
|
401
414
|
handleMouseup() {
|
|
402
415
|
if (!this.disabled) {
|
|
403
|
-
if (this.audio.duration === 0) {
|
|
416
|
+
if (this.audio.duration === 0 || Number.isNaN(this.audio.duration)) {
|
|
404
417
|
nfMessage.Message.warning(this.unloadTip);
|
|
405
418
|
this.paused = true;
|
|
406
419
|
this.betweenPlaying = false;
|
|
@@ -462,7 +475,7 @@ const _sfc_main = {
|
|
|
462
475
|
jumpToTime(time) {
|
|
463
476
|
if (!this.disabled) {
|
|
464
477
|
this.pauseAudio();
|
|
465
|
-
if (this.audio.duration === 0) {
|
|
478
|
+
if (this.audio.duration === 0 || Number.isNaN(this.audio.duration)) {
|
|
466
479
|
nfMessage.Message.warning(this.unloadTip);
|
|
467
480
|
this.paused = true;
|
|
468
481
|
this.betweenPlaying = false;
|
|
@@ -543,6 +556,7 @@ var _sfc_render = function render() {
|
|
|
543
556
|
},
|
|
544
557
|
on: {
|
|
545
558
|
"canplay": _vm.getDuration,
|
|
559
|
+
"error": _vm.loadError,
|
|
546
560
|
"timeupdate": _vm.updateTime,
|
|
547
561
|
"ended": _vm.handleAudioEnded
|
|
548
562
|
}
|
|
@@ -283,29 +283,36 @@ const _sfc_main = {
|
|
|
283
283
|
return window.location.protocol === "https:" || window.location.hostname === "localhost";
|
|
284
284
|
},
|
|
285
285
|
async startAudioCtx() {
|
|
286
|
+
var _a, _b;
|
|
286
287
|
if (this.isHighPrecision()) {
|
|
287
|
-
|
|
288
|
-
this.audioCtx
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
if (
|
|
295
|
-
|
|
296
|
-
if (
|
|
297
|
-
if (this.
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
288
|
+
try {
|
|
289
|
+
if (!this.audioCtx) {
|
|
290
|
+
this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
|
291
|
+
this.audioSource = this.audioCtx.createMediaElementSource(this.audio);
|
|
292
|
+
await ((_a = this.audioCtx.audioWorklet) == null ? void 0 : _a.addModule("data:application/javascript," + encodeURIComponent(this.audioWorkletProcessor)));
|
|
293
|
+
this.processor = new AudioWorkletNode(this.audioCtx, "tick");
|
|
294
|
+
this.audioSource.connect(this.processor).connect(this.audioCtx.destination);
|
|
295
|
+
if ((_b = this.processor) == null ? void 0 : _b.port) {
|
|
296
|
+
this.processor.port.onmessage = (event) => {
|
|
297
|
+
if (event.data.command === "tick") {
|
|
298
|
+
if (this.betweenPlaying) {
|
|
299
|
+
if (this.betweenEnd) {
|
|
300
|
+
if (this.debuglog) {
|
|
301
|
+
console.log(this.audio.currentTime);
|
|
302
|
+
}
|
|
303
|
+
if (this.audio.currentTime >= this.betweenEnd) {
|
|
304
|
+
this.pause();
|
|
305
|
+
}
|
|
306
|
+
}
|
|
302
307
|
}
|
|
303
308
|
}
|
|
304
|
-
}
|
|
309
|
+
};
|
|
305
310
|
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
|
|
311
|
+
} else {
|
|
312
|
+
this.audioCtx.resume();
|
|
313
|
+
}
|
|
314
|
+
} catch (e) {
|
|
315
|
+
console.log(e);
|
|
309
316
|
}
|
|
310
317
|
this.processor.port.postMessage({
|
|
311
318
|
command: "start"
|
|
@@ -331,10 +338,14 @@ const _sfc_main = {
|
|
|
331
338
|
await this.startAudioCtx();
|
|
332
339
|
this.audio.play();
|
|
333
340
|
},
|
|
341
|
+
loadError(e) {
|
|
342
|
+
this.$emit("error", e);
|
|
343
|
+
},
|
|
334
344
|
//视频在可以播放时触发
|
|
335
345
|
getDuration() {
|
|
336
346
|
this.totalTime = timeFormat(this.audio.duration);
|
|
337
347
|
this.audio.volume = this.volume;
|
|
348
|
+
this.$emit("canPlay", this.totalTime);
|
|
338
349
|
},
|
|
339
350
|
//进度条发生变化时触发
|
|
340
351
|
updateTime() {
|
|
@@ -360,7 +371,7 @@ const _sfc_main = {
|
|
|
360
371
|
},
|
|
361
372
|
betweenPlay() {
|
|
362
373
|
if (!this.disabled) {
|
|
363
|
-
if (this.audio.duration === 0) {
|
|
374
|
+
if (this.audio.duration === 0 || Number.isNaN(this.audio.duration)) {
|
|
364
375
|
Message.warning(this.unloadTip);
|
|
365
376
|
this.paused = true;
|
|
366
377
|
this.betweenPlaying = false;
|
|
@@ -378,8 +389,10 @@ const _sfc_main = {
|
|
|
378
389
|
//点击进度条更新进度
|
|
379
390
|
clickProgress(e) {
|
|
380
391
|
if (!this.disabled) {
|
|
381
|
-
if (this.audio.duration === 0) {
|
|
382
|
-
|
|
392
|
+
if (this.audio.duration === 0 || Number.isNaN(this.audio.duration)) {
|
|
393
|
+
if (!this.paused) {
|
|
394
|
+
Message.warning(this.unloadTip);
|
|
395
|
+
}
|
|
383
396
|
this.paused = true;
|
|
384
397
|
this.betweenPlaying = false;
|
|
385
398
|
return false;
|
|
@@ -398,7 +411,7 @@ const _sfc_main = {
|
|
|
398
411
|
//鼠标弹起
|
|
399
412
|
handleMouseup() {
|
|
400
413
|
if (!this.disabled) {
|
|
401
|
-
if (this.audio.duration === 0) {
|
|
414
|
+
if (this.audio.duration === 0 || Number.isNaN(this.audio.duration)) {
|
|
402
415
|
Message.warning(this.unloadTip);
|
|
403
416
|
this.paused = true;
|
|
404
417
|
this.betweenPlaying = false;
|
|
@@ -460,7 +473,7 @@ const _sfc_main = {
|
|
|
460
473
|
jumpToTime(time) {
|
|
461
474
|
if (!this.disabled) {
|
|
462
475
|
this.pauseAudio();
|
|
463
|
-
if (this.audio.duration === 0) {
|
|
476
|
+
if (this.audio.duration === 0 || Number.isNaN(this.audio.duration)) {
|
|
464
477
|
Message.warning(this.unloadTip);
|
|
465
478
|
this.paused = true;
|
|
466
479
|
this.betweenPlaying = false;
|
|
@@ -541,6 +554,7 @@ var _sfc_render = function render() {
|
|
|
541
554
|
},
|
|
542
555
|
on: {
|
|
543
556
|
"canplay": _vm.getDuration,
|
|
557
|
+
"error": _vm.loadError,
|
|
544
558
|
"timeupdate": _vm.updateTime,
|
|
545
559
|
"ended": _vm.handleAudioEnded
|
|
546
560
|
}
|
package/package/nf-audio.vue
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
:src="src"
|
|
12
12
|
v-show="false"
|
|
13
13
|
@canplay="getDuration"
|
|
14
|
+
@error="loadError"
|
|
14
15
|
@timeupdate="updateTime"
|
|
15
16
|
@ended="handleAudioEnded"
|
|
16
17
|
/>
|
|
@@ -450,28 +451,34 @@ export default {
|
|
|
450
451
|
},
|
|
451
452
|
async startAudioCtx() {
|
|
452
453
|
if (this.isHighPrecision()) {
|
|
453
|
-
|
|
454
|
-
this.audioCtx
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
if (
|
|
461
|
-
|
|
462
|
-
if (
|
|
463
|
-
if (this.
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
454
|
+
try {
|
|
455
|
+
if (!this.audioCtx) {
|
|
456
|
+
this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
|
457
|
+
this.audioSource = this.audioCtx.createMediaElementSource(this.audio);
|
|
458
|
+
await this.audioCtx.audioWorklet?.addModule('data:application/javascript,' + encodeURIComponent(this.audioWorkletProcessor));
|
|
459
|
+
this.processor = new AudioWorkletNode(this.audioCtx, 'tick');
|
|
460
|
+
this.audioSource.connect(this.processor).connect(this.audioCtx.destination);
|
|
461
|
+
if (this.processor?.port) {
|
|
462
|
+
this.processor.port.onmessage = (event) => {
|
|
463
|
+
if (event.data.command === 'tick') {
|
|
464
|
+
if (this.betweenPlaying) {
|
|
465
|
+
if (this.betweenEnd) {
|
|
466
|
+
if (this.debuglog) {
|
|
467
|
+
console.log(this.audio.currentTime)
|
|
468
|
+
}
|
|
469
|
+
if (this.audio.currentTime >= this.betweenEnd) {
|
|
470
|
+
this.pause()
|
|
471
|
+
}
|
|
472
|
+
}
|
|
468
473
|
}
|
|
469
474
|
}
|
|
470
|
-
}
|
|
475
|
+
};
|
|
471
476
|
}
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
|
|
477
|
+
} else {
|
|
478
|
+
this.audioCtx.resume()
|
|
479
|
+
}
|
|
480
|
+
} catch(e) {
|
|
481
|
+
console.log(e)
|
|
475
482
|
}
|
|
476
483
|
this.processor.port.postMessage({ command: 'start' });
|
|
477
484
|
}
|
|
@@ -495,10 +502,14 @@ export default {
|
|
|
495
502
|
await this.startAudioCtx()
|
|
496
503
|
this.audio.play()
|
|
497
504
|
},
|
|
505
|
+
loadError(e) {
|
|
506
|
+
this.$emit('error', e)
|
|
507
|
+
},
|
|
498
508
|
//视频在可以播放时触发
|
|
499
509
|
getDuration() {
|
|
500
510
|
this.totalTime = timeFormat(this.audio.duration)
|
|
501
511
|
this.audio.volume = this.volume
|
|
512
|
+
this.$emit('canPlay', this.totalTime)
|
|
502
513
|
},
|
|
503
514
|
//进度条发生变化时触发
|
|
504
515
|
updateTime() {
|
|
@@ -526,7 +537,7 @@ export default {
|
|
|
526
537
|
},
|
|
527
538
|
betweenPlay() {
|
|
528
539
|
if (!this.disabled) {
|
|
529
|
-
if (this.audio.duration === 0) {
|
|
540
|
+
if (this.audio.duration === 0 || Number.isNaN(this.audio.duration)) {
|
|
530
541
|
Message.warning(this.unloadTip)
|
|
531
542
|
this.paused = true
|
|
532
543
|
this.betweenPlaying = false
|
|
@@ -544,8 +555,10 @@ export default {
|
|
|
544
555
|
//点击进度条更新进度
|
|
545
556
|
clickProgress(e) {
|
|
546
557
|
if (!this.disabled) {
|
|
547
|
-
if (this.audio.duration === 0) {
|
|
548
|
-
|
|
558
|
+
if (this.audio.duration === 0 || Number.isNaN(this.audio.duration)) {
|
|
559
|
+
if (!this.paused) {
|
|
560
|
+
Message.warning(this.unloadTip)
|
|
561
|
+
}
|
|
549
562
|
this.paused = true
|
|
550
563
|
this.betweenPlaying = false
|
|
551
564
|
return false
|
|
@@ -567,7 +580,7 @@ export default {
|
|
|
567
580
|
//鼠标弹起
|
|
568
581
|
handleMouseup() {
|
|
569
582
|
if (!this.disabled) {
|
|
570
|
-
if (this.audio.duration === 0) {
|
|
583
|
+
if (this.audio.duration === 0 || Number.isNaN(this.audio.duration)) {
|
|
571
584
|
Message.warning(this.unloadTip)
|
|
572
585
|
this.paused = true
|
|
573
586
|
this.betweenPlaying = false
|
|
@@ -636,7 +649,7 @@ export default {
|
|
|
636
649
|
jumpToTime(time) {
|
|
637
650
|
if (!this.disabled) {
|
|
638
651
|
this.pauseAudio()
|
|
639
|
-
if (this.audio.duration === 0) {
|
|
652
|
+
if (this.audio.duration === 0 || Number.isNaN(this.audio.duration)) {
|
|
640
653
|
Message.warning(this.unloadTip)
|
|
641
654
|
this.paused = true
|
|
642
655
|
this.betweenPlaying = false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@94ai/nf-audio",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.67",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "liuxiangxiang <liuxiangxiang@94ai.com>",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"url": "http://94ai.gitlab.com/zoujiahe/common-ui.git"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@94ai/nf-theme-chalk": "^3.3.
|
|
17
|
+
"@94ai/nf-theme-chalk": "^3.3.67",
|
|
18
18
|
"vue-demi": "^0.14.5"
|
|
19
19
|
},
|
|
20
20
|
"peerDependenciesMeta": {
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"types": "lib/index.d.ts",
|
|
31
31
|
"main": "lib/nf-audio.cjs.js",
|
|
32
32
|
"module": "lib/nf-audio.esm-bundler.js",
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "2c752dc6246ba8252562937829c091ae21cca8f2"
|
|
34
34
|
}
|