@94ai/nf-audio 4.0.0 → 4.0.2
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 +68 -20
- package/lib/nf-audio.esm-bundler.js +68 -20
- package/package/nf-audio.vue +40 -21
- package/package.json +4 -4
package/lib/nf-audio.cjs.js
CHANGED
|
@@ -351,13 +351,15 @@ const _sfc_main = {
|
|
|
351
351
|
this.$emit("error", e);
|
|
352
352
|
},
|
|
353
353
|
//视频在可以播放时触发
|
|
354
|
-
getDuration() {
|
|
354
|
+
getDuration(e) {
|
|
355
355
|
this.totalTime = timeFormat(this.audio.duration);
|
|
356
356
|
this.audio.volume = this.volume;
|
|
357
357
|
this.$emit("canPlay", this.totalTime);
|
|
358
|
+
this.$emit("canplay", e);
|
|
358
359
|
},
|
|
359
360
|
//进度条发生变化时触发
|
|
360
|
-
updateTime() {
|
|
361
|
+
updateTime(e) {
|
|
362
|
+
this.$emit("updateTime", e);
|
|
361
363
|
if (!this.$refs.progressContainer)
|
|
362
364
|
return;
|
|
363
365
|
this.currentTime = timeFormat(this.audio.currentTime);
|
|
@@ -390,7 +392,8 @@ const _sfc_main = {
|
|
|
390
392
|
this.jumpToTime(this.betweenStart);
|
|
391
393
|
}
|
|
392
394
|
},
|
|
393
|
-
handleAudioEnded() {
|
|
395
|
+
handleAudioEnded(e) {
|
|
396
|
+
this.$emit("ended", e);
|
|
394
397
|
this.$refs.progressCurrent.style.width = this.$refs.progressContainer.clientWidth + "px";
|
|
395
398
|
this.$refs.progressBar.style.left = this.$refs.progressContainer.clientWidth - this.$refs.progressBar.clientWidth / 2 + "px";
|
|
396
399
|
this.pause();
|
|
@@ -508,12 +511,10 @@ const _sfc_main = {
|
|
|
508
511
|
openWindow() {
|
|
509
512
|
window.open(this.src);
|
|
510
513
|
},
|
|
511
|
-
calcMoveX() {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
this.$refs.progressBar.style.left = MoveX - this.$refs.progressBar.clientWidth / 2 + "px";
|
|
516
|
-
}
|
|
514
|
+
async calcMoveX() {
|
|
515
|
+
let MoveX = this.$refs.progressContainer.clientWidth * (this.audio.currentTime / this.audio.duration);
|
|
516
|
+
this.$refs.progressCurrent.style.width = MoveX + "px";
|
|
517
|
+
this.$refs.progressBar.style.left = MoveX - this.$refs.progressBar.clientWidth / 2 + "px";
|
|
517
518
|
},
|
|
518
519
|
checkAudioEffectNull() {
|
|
519
520
|
return this.audio.duration === 0 || Number.isNaN(this.audio.duration);
|
|
@@ -528,16 +529,9 @@ const _sfc_main = {
|
|
|
528
529
|
return false;
|
|
529
530
|
}
|
|
530
531
|
if (time >= this.audio.duration) {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
this.betweenPlaying = false;
|
|
535
|
-
} else {
|
|
536
|
-
this.audio.currentTime = this.audio.duration;
|
|
537
|
-
this.currentTime = timeFormat(this.audio.currentTime);
|
|
538
|
-
this.calcMoveX();
|
|
539
|
-
this.playAudio();
|
|
540
|
-
}
|
|
532
|
+
this.audio.currentTime = this.audio.duration;
|
|
533
|
+
this.currentTime = timeFormat(this.audio.currentTime);
|
|
534
|
+
this.calcMoveX();
|
|
541
535
|
return false;
|
|
542
536
|
} else if (time >= 0 && time < this.audio.duration) {
|
|
543
537
|
this.audio.currentTime = time;
|
|
@@ -605,7 +599,61 @@ var _sfc_render = function render() {
|
|
|
605
599
|
"canplay": _vm.getDuration,
|
|
606
600
|
"error": _vm.loadError,
|
|
607
601
|
"timeupdate": _vm.updateTime,
|
|
608
|
-
"ended": _vm.handleAudioEnded
|
|
602
|
+
"ended": _vm.handleAudioEnded,
|
|
603
|
+
"abort": function($event) {
|
|
604
|
+
return _vm.$emit("abort", $event);
|
|
605
|
+
},
|
|
606
|
+
"canplaythrough": function($event) {
|
|
607
|
+
return _vm.$emit("canplaythrough", $event);
|
|
608
|
+
},
|
|
609
|
+
"durationchange": function($event) {
|
|
610
|
+
return _vm.$emit("durationchange", $event);
|
|
611
|
+
},
|
|
612
|
+
"emptied": function($event) {
|
|
613
|
+
return _vm.$emit("emptied", $event);
|
|
614
|
+
},
|
|
615
|
+
"loadeddata": function($event) {
|
|
616
|
+
return _vm.$emit("loadeddata", $event);
|
|
617
|
+
},
|
|
618
|
+
"loadedmetadata": function($event) {
|
|
619
|
+
return _vm.$emit("loadedmetadata", $event);
|
|
620
|
+
},
|
|
621
|
+
"loadstart": function($event) {
|
|
622
|
+
return _vm.$emit("loadstart", $event);
|
|
623
|
+
},
|
|
624
|
+
"pause": function($event) {
|
|
625
|
+
return _vm.$emit("pause", $event);
|
|
626
|
+
},
|
|
627
|
+
"play": function($event) {
|
|
628
|
+
return _vm.$emit("play", $event);
|
|
629
|
+
},
|
|
630
|
+
"playing": function($event) {
|
|
631
|
+
return _vm.$emit("playing", $event);
|
|
632
|
+
},
|
|
633
|
+
"progress": function($event) {
|
|
634
|
+
return _vm.$emit("progress", $event);
|
|
635
|
+
},
|
|
636
|
+
"ratechange": function($event) {
|
|
637
|
+
return _vm.$emit("ratechange", $event);
|
|
638
|
+
},
|
|
639
|
+
"seeked": function($event) {
|
|
640
|
+
return _vm.$emit("seeked", $event);
|
|
641
|
+
},
|
|
642
|
+
"seeking": function($event) {
|
|
643
|
+
return _vm.$emit("seeking", $event);
|
|
644
|
+
},
|
|
645
|
+
"stalled": function($event) {
|
|
646
|
+
return _vm.$emit("stalled", $event);
|
|
647
|
+
},
|
|
648
|
+
"suspend": function($event) {
|
|
649
|
+
return _vm.$emit("suspend", $event);
|
|
650
|
+
},
|
|
651
|
+
"volumechange": function($event) {
|
|
652
|
+
return _vm.$emit("volumechange", $event);
|
|
653
|
+
},
|
|
654
|
+
"waiting": function($event) {
|
|
655
|
+
return _vm.$emit("waiting", $event);
|
|
656
|
+
}
|
|
609
657
|
}
|
|
610
658
|
}), _vm.showJumpTime ? _vm._t("jump", function() {
|
|
611
659
|
return [_c("div", {
|
|
@@ -349,13 +349,15 @@ const _sfc_main = {
|
|
|
349
349
|
this.$emit("error", e);
|
|
350
350
|
},
|
|
351
351
|
//视频在可以播放时触发
|
|
352
|
-
getDuration() {
|
|
352
|
+
getDuration(e) {
|
|
353
353
|
this.totalTime = timeFormat(this.audio.duration);
|
|
354
354
|
this.audio.volume = this.volume;
|
|
355
355
|
this.$emit("canPlay", this.totalTime);
|
|
356
|
+
this.$emit("canplay", e);
|
|
356
357
|
},
|
|
357
358
|
//进度条发生变化时触发
|
|
358
|
-
updateTime() {
|
|
359
|
+
updateTime(e) {
|
|
360
|
+
this.$emit("updateTime", e);
|
|
359
361
|
if (!this.$refs.progressContainer)
|
|
360
362
|
return;
|
|
361
363
|
this.currentTime = timeFormat(this.audio.currentTime);
|
|
@@ -388,7 +390,8 @@ const _sfc_main = {
|
|
|
388
390
|
this.jumpToTime(this.betweenStart);
|
|
389
391
|
}
|
|
390
392
|
},
|
|
391
|
-
handleAudioEnded() {
|
|
393
|
+
handleAudioEnded(e) {
|
|
394
|
+
this.$emit("ended", e);
|
|
392
395
|
this.$refs.progressCurrent.style.width = this.$refs.progressContainer.clientWidth + "px";
|
|
393
396
|
this.$refs.progressBar.style.left = this.$refs.progressContainer.clientWidth - this.$refs.progressBar.clientWidth / 2 + "px";
|
|
394
397
|
this.pause();
|
|
@@ -506,12 +509,10 @@ const _sfc_main = {
|
|
|
506
509
|
openWindow() {
|
|
507
510
|
window.open(this.src);
|
|
508
511
|
},
|
|
509
|
-
calcMoveX() {
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
this.$refs.progressBar.style.left = MoveX - this.$refs.progressBar.clientWidth / 2 + "px";
|
|
514
|
-
}
|
|
512
|
+
async calcMoveX() {
|
|
513
|
+
let MoveX = this.$refs.progressContainer.clientWidth * (this.audio.currentTime / this.audio.duration);
|
|
514
|
+
this.$refs.progressCurrent.style.width = MoveX + "px";
|
|
515
|
+
this.$refs.progressBar.style.left = MoveX - this.$refs.progressBar.clientWidth / 2 + "px";
|
|
515
516
|
},
|
|
516
517
|
checkAudioEffectNull() {
|
|
517
518
|
return this.audio.duration === 0 || Number.isNaN(this.audio.duration);
|
|
@@ -526,16 +527,9 @@ const _sfc_main = {
|
|
|
526
527
|
return false;
|
|
527
528
|
}
|
|
528
529
|
if (time >= this.audio.duration) {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
this.betweenPlaying = false;
|
|
533
|
-
} else {
|
|
534
|
-
this.audio.currentTime = this.audio.duration;
|
|
535
|
-
this.currentTime = timeFormat(this.audio.currentTime);
|
|
536
|
-
this.calcMoveX();
|
|
537
|
-
this.playAudio();
|
|
538
|
-
}
|
|
530
|
+
this.audio.currentTime = this.audio.duration;
|
|
531
|
+
this.currentTime = timeFormat(this.audio.currentTime);
|
|
532
|
+
this.calcMoveX();
|
|
539
533
|
return false;
|
|
540
534
|
} else if (time >= 0 && time < this.audio.duration) {
|
|
541
535
|
this.audio.currentTime = time;
|
|
@@ -603,7 +597,61 @@ var _sfc_render = function render() {
|
|
|
603
597
|
"canplay": _vm.getDuration,
|
|
604
598
|
"error": _vm.loadError,
|
|
605
599
|
"timeupdate": _vm.updateTime,
|
|
606
|
-
"ended": _vm.handleAudioEnded
|
|
600
|
+
"ended": _vm.handleAudioEnded,
|
|
601
|
+
"abort": function($event) {
|
|
602
|
+
return _vm.$emit("abort", $event);
|
|
603
|
+
},
|
|
604
|
+
"canplaythrough": function($event) {
|
|
605
|
+
return _vm.$emit("canplaythrough", $event);
|
|
606
|
+
},
|
|
607
|
+
"durationchange": function($event) {
|
|
608
|
+
return _vm.$emit("durationchange", $event);
|
|
609
|
+
},
|
|
610
|
+
"emptied": function($event) {
|
|
611
|
+
return _vm.$emit("emptied", $event);
|
|
612
|
+
},
|
|
613
|
+
"loadeddata": function($event) {
|
|
614
|
+
return _vm.$emit("loadeddata", $event);
|
|
615
|
+
},
|
|
616
|
+
"loadedmetadata": function($event) {
|
|
617
|
+
return _vm.$emit("loadedmetadata", $event);
|
|
618
|
+
},
|
|
619
|
+
"loadstart": function($event) {
|
|
620
|
+
return _vm.$emit("loadstart", $event);
|
|
621
|
+
},
|
|
622
|
+
"pause": function($event) {
|
|
623
|
+
return _vm.$emit("pause", $event);
|
|
624
|
+
},
|
|
625
|
+
"play": function($event) {
|
|
626
|
+
return _vm.$emit("play", $event);
|
|
627
|
+
},
|
|
628
|
+
"playing": function($event) {
|
|
629
|
+
return _vm.$emit("playing", $event);
|
|
630
|
+
},
|
|
631
|
+
"progress": function($event) {
|
|
632
|
+
return _vm.$emit("progress", $event);
|
|
633
|
+
},
|
|
634
|
+
"ratechange": function($event) {
|
|
635
|
+
return _vm.$emit("ratechange", $event);
|
|
636
|
+
},
|
|
637
|
+
"seeked": function($event) {
|
|
638
|
+
return _vm.$emit("seeked", $event);
|
|
639
|
+
},
|
|
640
|
+
"seeking": function($event) {
|
|
641
|
+
return _vm.$emit("seeking", $event);
|
|
642
|
+
},
|
|
643
|
+
"stalled": function($event) {
|
|
644
|
+
return _vm.$emit("stalled", $event);
|
|
645
|
+
},
|
|
646
|
+
"suspend": function($event) {
|
|
647
|
+
return _vm.$emit("suspend", $event);
|
|
648
|
+
},
|
|
649
|
+
"volumechange": function($event) {
|
|
650
|
+
return _vm.$emit("volumechange", $event);
|
|
651
|
+
},
|
|
652
|
+
"waiting": function($event) {
|
|
653
|
+
return _vm.$emit("waiting", $event);
|
|
654
|
+
}
|
|
607
655
|
}
|
|
608
656
|
}), _vm.showJumpTime ? _vm._t("jump", function() {
|
|
609
657
|
return [_c("div", {
|
package/package/nf-audio.vue
CHANGED
|
@@ -14,6 +14,24 @@
|
|
|
14
14
|
@error="loadError"
|
|
15
15
|
@timeupdate="updateTime"
|
|
16
16
|
@ended="handleAudioEnded"
|
|
17
|
+
@abort="$emit('abort', $event)"
|
|
18
|
+
@canplaythrough="$emit('canplaythrough', $event)"
|
|
19
|
+
@durationchange ="$emit('durationchange', $event)"
|
|
20
|
+
@emptied="$emit('emptied', $event)"
|
|
21
|
+
@loadeddata="$emit('loadeddata', $event)"
|
|
22
|
+
@loadedmetadata ="$emit('loadedmetadata', $event)"
|
|
23
|
+
@loadstart ="$emit('loadstart', $event)"
|
|
24
|
+
@pause="$emit('pause', $event)"
|
|
25
|
+
@play="$emit('play', $event)"
|
|
26
|
+
@playing="$emit('playing', $event)"
|
|
27
|
+
@progress="$emit('progress', $event)"
|
|
28
|
+
@ratechange="$emit('ratechange', $event)"
|
|
29
|
+
@seeked="$emit('seeked', $event)"
|
|
30
|
+
@seeking="$emit('seeking', $event)"
|
|
31
|
+
@stalled="$emit('stalled', $event)"
|
|
32
|
+
@suspend="$emit('suspend', $event)"
|
|
33
|
+
@volumechange="$emit('volumechange', $event)"
|
|
34
|
+
@waiting="$emit('waiting', $event)"
|
|
17
35
|
/>
|
|
18
36
|
|
|
19
37
|
<!-- 跳帧 -->
|
|
@@ -515,13 +533,15 @@ export default {
|
|
|
515
533
|
this.$emit('error', e)
|
|
516
534
|
},
|
|
517
535
|
//视频在可以播放时触发
|
|
518
|
-
getDuration() {
|
|
536
|
+
getDuration(e) {
|
|
519
537
|
this.totalTime = timeFormat(this.audio.duration)
|
|
520
538
|
this.audio.volume = this.volume
|
|
521
539
|
this.$emit('canPlay', this.totalTime)
|
|
540
|
+
this.$emit('canplay', e)
|
|
522
541
|
},
|
|
523
542
|
//进度条发生变化时触发
|
|
524
|
-
updateTime() {
|
|
543
|
+
updateTime(e) {
|
|
544
|
+
this.$emit('updateTime', e)
|
|
525
545
|
if (!this.$refs.progressContainer) return
|
|
526
546
|
// 设置当前时间
|
|
527
547
|
this.currentTime = timeFormat(this.audio.currentTime)
|
|
@@ -556,7 +576,8 @@ export default {
|
|
|
556
576
|
this.jumpToTime(this.betweenStart)
|
|
557
577
|
}
|
|
558
578
|
},
|
|
559
|
-
handleAudioEnded() {
|
|
579
|
+
handleAudioEnded(e) {
|
|
580
|
+
this.$emit('ended', e)
|
|
560
581
|
this.$refs.progressCurrent.style.width = this.$refs.progressContainer.clientWidth + 'px'
|
|
561
582
|
this.$refs.progressBar.style.left = this.$refs.progressContainer.clientWidth - (this.$refs.progressBar.clientWidth / 2) + 'px'
|
|
562
583
|
this.pause()
|
|
@@ -682,14 +703,12 @@ export default {
|
|
|
682
703
|
openWindow() {
|
|
683
704
|
window.open(this.src)
|
|
684
705
|
},
|
|
685
|
-
calcMoveX() {
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
this.$refs.progressBar.style.left = MoveX - (this.$refs.progressBar.clientWidth / 2) + 'px'
|
|
692
|
-
}
|
|
706
|
+
async calcMoveX() {
|
|
707
|
+
// 设置当前时间
|
|
708
|
+
let MoveX = this.$refs.progressContainer.clientWidth * (this.audio.currentTime / this.audio.duration)
|
|
709
|
+
//播放时更新距离
|
|
710
|
+
this.$refs.progressCurrent.style.width = MoveX + 'px'
|
|
711
|
+
this.$refs.progressBar.style.left = MoveX - (this.$refs.progressBar.clientWidth / 2) + 'px'
|
|
693
712
|
},
|
|
694
713
|
checkAudioEffectNull() {
|
|
695
714
|
return this.audio.duration === 0 || Number.isNaN(this.audio.duration)
|
|
@@ -704,16 +723,16 @@ export default {
|
|
|
704
723
|
return false
|
|
705
724
|
}
|
|
706
725
|
if (time >= this.audio.duration) {
|
|
707
|
-
if (time > this.audio.duration) {
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
}
|
|
726
|
+
// if (time > this.audio.duration) {
|
|
727
|
+
// Message.warning(this.crossTimeTip)
|
|
728
|
+
// console.error(this.crossTimeTip)
|
|
729
|
+
// this.paused = true
|
|
730
|
+
// this.betweenPlaying = false
|
|
731
|
+
// } else {
|
|
732
|
+
this.audio.currentTime = this.audio.duration
|
|
733
|
+
this.currentTime = timeFormat(this.audio.currentTime)
|
|
734
|
+
this.calcMoveX()
|
|
735
|
+
// }
|
|
717
736
|
return false
|
|
718
737
|
} else if (time >= 0 && time < this.audio.duration) {
|
|
719
738
|
this.audio.currentTime = time
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@94ai/nf-audio",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
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": "^4.0.
|
|
18
|
-
"@94ai/nf-theme-chalk": "^4.0.
|
|
17
|
+
"@94ai/nf-message": "^4.0.2",
|
|
18
|
+
"@94ai/nf-theme-chalk": "^4.0.2",
|
|
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": "608b84fe8c8fdce3264d69acaed34642a0c9d3d1"
|
|
35
35
|
}
|