@94ai/nf-audio 3.3.67 → 3.3.68

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.
@@ -388,6 +388,15 @@ const _sfc_main = {
388
388
  this.$refs.progressBar.style.left = this.$refs.progressContainer.clientWidth - this.$refs.progressBar.clientWidth / 2 + "px";
389
389
  this.pause();
390
390
  },
391
+ getOffsetX(ev) {
392
+ const e = ev || window.event;
393
+ const srcObj = e.target || e.srcElement;
394
+ if (e.offsetX) {
395
+ return e.offsetX;
396
+ }
397
+ const rect = srcObj.getBoundingClientRect();
398
+ return e.clientX - rect.left;
399
+ },
391
400
  //点击进度条更新进度
392
401
  clickProgress(e) {
393
402
  if (!this.disabled) {
@@ -399,8 +408,8 @@ const _sfc_main = {
399
408
  this.betweenPlaying = false;
400
409
  return false;
401
410
  }
402
- this.updateProgress(e.offsetX);
403
- this.$emit("updateProgress", e.offsetX);
411
+ this.updateProgress(this.getOffsetX(e));
412
+ this.$emit("updateProgress", this.getOffsetX(e));
404
413
  }
405
414
  },
406
415
  //更新进度
@@ -438,8 +447,8 @@ const _sfc_main = {
438
447
  this.paused = true;
439
448
  this.betweenPlaying = false;
440
449
  const progressContainer = this.$refs.progressContainer;
441
- this.moveMin = progressContainer.offsetParent.offsetLeft + progressContainer.offsetLeft;
442
- this.moveMax = progressContainer.offsetParent.offsetLeft + progressContainer.offsetLeft + progressContainer.clientWidth;
450
+ this.moveMin = progressContainer.getBoundingClientRect().left;
451
+ this.moveMax = progressContainer.getBoundingClientRect().left + progressContainer.clientWidth;
443
452
  this.progressBarWidth = this.$refs.progressBar.clientWidth / 2;
444
453
  document.addEventListener("mousemove", this.moveX);
445
454
  document.addEventListener("mouseup", () => {
@@ -386,6 +386,15 @@ const _sfc_main = {
386
386
  this.$refs.progressBar.style.left = this.$refs.progressContainer.clientWidth - this.$refs.progressBar.clientWidth / 2 + "px";
387
387
  this.pause();
388
388
  },
389
+ getOffsetX(ev) {
390
+ const e = ev || window.event;
391
+ const srcObj = e.target || e.srcElement;
392
+ if (e.offsetX) {
393
+ return e.offsetX;
394
+ }
395
+ const rect = srcObj.getBoundingClientRect();
396
+ return e.clientX - rect.left;
397
+ },
389
398
  //点击进度条更新进度
390
399
  clickProgress(e) {
391
400
  if (!this.disabled) {
@@ -397,8 +406,8 @@ const _sfc_main = {
397
406
  this.betweenPlaying = false;
398
407
  return false;
399
408
  }
400
- this.updateProgress(e.offsetX);
401
- this.$emit("updateProgress", e.offsetX);
409
+ this.updateProgress(this.getOffsetX(e));
410
+ this.$emit("updateProgress", this.getOffsetX(e));
402
411
  }
403
412
  },
404
413
  //更新进度
@@ -436,8 +445,8 @@ const _sfc_main = {
436
445
  this.paused = true;
437
446
  this.betweenPlaying = false;
438
447
  const progressContainer = this.$refs.progressContainer;
439
- this.moveMin = progressContainer.offsetParent.offsetLeft + progressContainer.offsetLeft;
440
- this.moveMax = progressContainer.offsetParent.offsetLeft + progressContainer.offsetLeft + progressContainer.clientWidth;
448
+ this.moveMin = progressContainer.getBoundingClientRect().left;
449
+ this.moveMax = progressContainer.getBoundingClientRect().left + progressContainer.clientWidth;
441
450
  this.progressBarWidth = this.$refs.progressBar.clientWidth / 2;
442
451
  document.addEventListener("mousemove", this.moveX);
443
452
  document.addEventListener("mouseup", () => {
@@ -43,7 +43,7 @@
43
43
  </slot>
44
44
 
45
45
  <!-- 快退-->
46
- <slot name="fastBack" v-if="backSecond" >
46
+ <slot name="fastBack" v-if="backSecond">
47
47
  <el-tooltip class="nf-audio-pre"
48
48
  placement="top"
49
49
  :disabled="disabled"
@@ -173,7 +173,7 @@ export default {
173
173
  default: false
174
174
  },
175
175
  size: {
176
- type: String,
176
+ type: String
177
177
  },
178
178
  speedDesc: {
179
179
  type: String,
@@ -341,7 +341,7 @@ export default {
341
341
  try {
342
342
  this.audioCtx?.close()
343
343
  } catch (e) {
344
- //
344
+ //
345
345
  } finally {
346
346
  this.audioCtx = undefined
347
347
  }
@@ -415,7 +415,7 @@ export default {
415
415
  if (!this.disabled) {
416
416
  if (this.audio.readyState >= 2) {
417
417
  // 如果音频资源已加载元数据或更多,可以播放
418
- if(this.audio.paused) {
418
+ if (this.audio.paused) {
419
419
  this.playAudio()
420
420
  } else {
421
421
  this.pauseAudio()
@@ -433,7 +433,7 @@ export default {
433
433
  },
434
434
  suspendAudioCtx() {
435
435
  try {
436
- this.processor?.port?.postMessage({ command: 'end' });
436
+ this.processor?.port?.postMessage({ command: 'end' })
437
437
  } catch (e) {
438
438
  //
439
439
  }
@@ -453,11 +453,11 @@ export default {
453
453
  if (this.isHighPrecision()) {
454
454
  try {
455
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);
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
461
  if (this.processor?.port) {
462
462
  this.processor.port.onmessage = (event) => {
463
463
  if (event.data.command === 'tick') {
@@ -472,15 +472,15 @@ export default {
472
472
  }
473
473
  }
474
474
  }
475
- };
475
+ }
476
476
  }
477
477
  } else {
478
478
  this.audioCtx.resume()
479
479
  }
480
- } catch(e) {
480
+ } catch (e) {
481
481
  console.log(e)
482
482
  }
483
- this.processor.port.postMessage({ command: 'start' });
483
+ this.processor.port.postMessage({ command: 'start' })
484
484
  }
485
485
  },
486
486
  pause() {
@@ -552,6 +552,15 @@ export default {
552
552
  this.$refs.progressBar.style.left = this.$refs.progressContainer.clientWidth - (this.$refs.progressBar.clientWidth / 2) + 'px'
553
553
  this.pause()
554
554
  },
555
+ getOffsetX(ev) {
556
+ const e = ev || window.event
557
+ const srcObj = e.target || e.srcElement
558
+ if (e.offsetX) {
559
+ return e.offsetX
560
+ }
561
+ const rect = srcObj.getBoundingClientRect()
562
+ return e.clientX - rect.left
563
+ },
555
564
  //点击进度条更新进度
556
565
  clickProgress(e) {
557
566
  if (!this.disabled) {
@@ -563,8 +572,8 @@ export default {
563
572
  this.betweenPlaying = false
564
573
  return false
565
574
  }
566
- this.updateProgress(e.offsetX)
567
- this.$emit('updateProgress', e.offsetX)
575
+ this.updateProgress(this.getOffsetX(e))
576
+ this.$emit('updateProgress', this.getOffsetX(e))
568
577
  }
569
578
  },
570
579
  //更新进度
@@ -606,9 +615,9 @@ export default {
606
615
  this.betweenPlaying = false
607
616
  const progressContainer = this.$refs.progressContainer
608
617
  //进度条 左 边距离页面左边的距离 移动最小值
609
- this.moveMin = progressContainer.offsetParent.offsetLeft + progressContainer.offsetLeft
618
+ this.moveMin = progressContainer.getBoundingClientRect().left
610
619
  //进度条 右 边距离页面左边的距离 移动最大值
611
- this.moveMax = progressContainer.offsetParent.offsetLeft + progressContainer.offsetLeft + progressContainer.clientWidth
620
+ this.moveMax = progressContainer.getBoundingClientRect().left + progressContainer.clientWidth
612
621
  //progressBar的宽度
613
622
  this.progressBarWidth = (this.$refs.progressBar.clientWidth / 2)
614
623
  //获取当前鼠标的位置 X
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-audio",
3
- "version": "3.3.67",
3
+ "version": "3.3.68",
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.67",
17
+ "@94ai/nf-theme-chalk": "^3.3.68",
18
18
  "vue-demi": "^0.14.5"
19
19
  },
20
20
  "peerDependenciesMeta": {