@94ai/nf-audio 3.3.64 → 3.3.66

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.
@@ -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
- if (!this.audioCtx) {
290
- this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
291
- this.audioSource = this.audioCtx.createMediaElementSource(this.audio);
292
- await this.audioCtx.audioWorklet.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
- this.processor.port.onmessage = (event) => {
296
- if (event.data.command === "tick") {
297
- if (this.betweenPlaying) {
298
- if (this.betweenEnd) {
299
- if (this.debuglog) {
300
- console.log(this.audio.currentTime);
301
- }
302
- if (this.audio.currentTime >= this.betweenEnd) {
303
- this.pause();
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
- } else {
310
- this.audioCtx.resume();
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() {
@@ -386,10 +397,8 @@ const _sfc_main = {
386
397
  this.betweenPlaying = false;
387
398
  return false;
388
399
  }
389
- if (!this.audio.paused) {
390
- this.updateProgress(e.offsetX);
391
- this.$emit("updateProgress", e.offsetX);
392
- }
400
+ this.updateProgress(e.offsetX);
401
+ this.$emit("updateProgress", e.offsetX);
393
402
  }
394
403
  },
395
404
  //更新进度
@@ -545,6 +554,7 @@ var _sfc_render = function render() {
545
554
  },
546
555
  on: {
547
556
  "canplay": _vm.getDuration,
557
+ "error": _vm.loadError,
548
558
  "timeupdate": _vm.updateTime,
549
559
  "ended": _vm.handleAudioEnded
550
560
  }
@@ -643,7 +653,10 @@ var _sfc_render = function render() {
643
653
  ref: "progressBar",
644
654
  staticClass: "nf-audio-progress-bar",
645
655
  on: {
646
- "mousedown": _vm.handleMousedown
656
+ "mousedown": _vm.handleMousedown,
657
+ "click": function($event) {
658
+ $event.stopPropagation();
659
+ }
647
660
  }
648
661
  })])])];
649
662
  }), _vm.forwardSecond ? _vm._t("fastForward", function() {
@@ -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
- if (!this.audioCtx) {
288
- this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
289
- this.audioSource = this.audioCtx.createMediaElementSource(this.audio);
290
- await this.audioCtx.audioWorklet.addModule("data:application/javascript," + encodeURIComponent(this.audioWorkletProcessor));
291
- this.processor = new AudioWorkletNode(this.audioCtx, "tick");
292
- this.audioSource.connect(this.processor).connect(this.audioCtx.destination);
293
- this.processor.port.onmessage = (event) => {
294
- if (event.data.command === "tick") {
295
- if (this.betweenPlaying) {
296
- if (this.betweenEnd) {
297
- if (this.debuglog) {
298
- console.log(this.audio.currentTime);
299
- }
300
- if (this.audio.currentTime >= this.betweenEnd) {
301
- this.pause();
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
- } else {
308
- this.audioCtx.resume();
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() {
@@ -384,10 +395,8 @@ const _sfc_main = {
384
395
  this.betweenPlaying = false;
385
396
  return false;
386
397
  }
387
- if (!this.audio.paused) {
388
- this.updateProgress(e.offsetX);
389
- this.$emit("updateProgress", e.offsetX);
390
- }
398
+ this.updateProgress(e.offsetX);
399
+ this.$emit("updateProgress", e.offsetX);
391
400
  }
392
401
  },
393
402
  //更新进度
@@ -543,6 +552,7 @@ var _sfc_render = function render() {
543
552
  },
544
553
  on: {
545
554
  "canplay": _vm.getDuration,
555
+ "error": _vm.loadError,
546
556
  "timeupdate": _vm.updateTime,
547
557
  "ended": _vm.handleAudioEnded
548
558
  }
@@ -641,7 +651,10 @@ var _sfc_render = function render() {
641
651
  ref: "progressBar",
642
652
  staticClass: "nf-audio-progress-bar",
643
653
  on: {
644
- "mousedown": _vm.handleMousedown
654
+ "mousedown": _vm.handleMousedown,
655
+ "click": function($event) {
656
+ $event.stopPropagation();
657
+ }
645
658
  }
646
659
  })])])];
647
660
  }), _vm.forwardSecond ? _vm._t("fastForward", function() {
@@ -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
  />
@@ -70,6 +71,7 @@
70
71
  <span class="nf-audio-progress-bar"
71
72
  ref="progressBar"
72
73
  @mousedown="handleMousedown"
74
+ @click.stop
73
75
  />
74
76
  </div>
75
77
  </div>
@@ -449,28 +451,34 @@ export default {
449
451
  },
450
452
  async startAudioCtx() {
451
453
  if (this.isHighPrecision()) {
452
- if (!this.audioCtx) {
453
- this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
454
- this.audioSource = this.audioCtx.createMediaElementSource(this.audio);
455
- await this.audioCtx.audioWorklet.addModule('data:application/javascript,' + encodeURIComponent(this.audioWorkletProcessor));
456
- this.processor = new AudioWorkletNode(this.audioCtx, 'tick');
457
- this.audioSource.connect(this.processor).connect(this.audioCtx.destination);
458
- this.processor.port.onmessage = (event) => {
459
- if (event.data.command === 'tick') {
460
- if (this.betweenPlaying) {
461
- if (this.betweenEnd) {
462
- if (this.debuglog) {
463
- console.log(this.audio.currentTime)
464
- }
465
- if (this.audio.currentTime >= this.betweenEnd) {
466
- this.pause()
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
+ }
467
473
  }
468
474
  }
469
- }
475
+ };
470
476
  }
471
- };
472
- } else {
473
- this.audioCtx.resume()
477
+ } else {
478
+ this.audioCtx.resume()
479
+ }
480
+ } catch(e) {
481
+ console.log(e)
474
482
  }
475
483
  this.processor.port.postMessage({ command: 'start' });
476
484
  }
@@ -494,10 +502,14 @@ export default {
494
502
  await this.startAudioCtx()
495
503
  this.audio.play()
496
504
  },
505
+ loadError(e) {
506
+ this.$emit('error', e)
507
+ },
497
508
  //视频在可以播放时触发
498
509
  getDuration() {
499
510
  this.totalTime = timeFormat(this.audio.duration)
500
511
  this.audio.volume = this.volume
512
+ this.$emit('canPlay', this.totalTime)
501
513
  },
502
514
  //进度条发生变化时触发
503
515
  updateTime() {
@@ -549,11 +561,8 @@ export default {
549
561
  this.betweenPlaying = false
550
562
  return false
551
563
  }
552
- //如果不是正在移动 和 没有暂停播放就执行
553
- if (!this.audio.paused) {
554
- this.updateProgress(e.offsetX)
555
- this.$emit('updateProgress', e.offsetX)
556
- }
564
+ this.updateProgress(e.offsetX)
565
+ this.$emit('updateProgress', e.offsetX)
557
566
  }
558
567
  },
559
568
  //更新进度
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-audio",
3
- "version": "3.3.64",
3
+ "version": "3.3.66",
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.64",
17
+ "@94ai/nf-theme-chalk": "^3.3.66",
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": "e4fb754b3e4a7deb29d4200826491496fd813aa9"
33
+ "gitHead": "0b5045a8e003b4ddc7da70fc5d839120d6ccba94"
34
34
  }