@94ai/nf-audio 3.1.13
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/.eslintrc.cjs +49 -0
- package/README.md +11 -0
- package/components.d.ts +8 -0
- package/lib/index.d.ts +147 -0
- package/lib/more-btn.vue.d.ts +5 -0
- package/lib/nf-audio.cjs.js +480 -0
- package/lib/nf-audio.esm-bundler.js +480 -0
- package/lib/nf-audio.vue.d.ts +51 -0
- package/lib/style/css.d.ts +1 -0
- package/lib/style/css.js +1 -0
- package/lib/style/index.d.ts +1 -0
- package/lib/style/index.js +1 -0
- package/lib/volume-tool.vue.d.ts +15 -0
- package/package/index.ts +8 -0
- package/package/more-btn.vue +43 -0
- package/package/nf-audio.vue +286 -0
- package/package/style/css.ts +1 -0
- package/package/style/index.ts +1 -0
- package/package/volume-tool.vue +51 -0
- package/package.json +34 -0
- package/postcss.config.js +8 -0
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"root": true,
|
|
3
|
+
"env": {
|
|
4
|
+
"node": true
|
|
5
|
+
},
|
|
6
|
+
"extends": [
|
|
7
|
+
"plugin:vue/essential"
|
|
8
|
+
],
|
|
9
|
+
"parser": "vue-eslint-parser",
|
|
10
|
+
"parserOptions": {
|
|
11
|
+
"parser": "@typescript-eslint/parser",
|
|
12
|
+
"ecmaVersion": 2020,
|
|
13
|
+
"sourceType": "module"
|
|
14
|
+
},
|
|
15
|
+
"rules": {
|
|
16
|
+
"@typescript-eslint/ban-ts-ignore": "off",
|
|
17
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
18
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
19
|
+
"@typescript-eslint/no-var-requires": "off",
|
|
20
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
21
|
+
"vue/custom-event-name-casing": "off",
|
|
22
|
+
"no-use-before-define": "off",
|
|
23
|
+
"@typescript-eslint/no-use-before-define": "off",
|
|
24
|
+
"@typescript-eslint/ban-ts-comment": "off",
|
|
25
|
+
"@typescript-eslint/ban-types": "off",
|
|
26
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
27
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
28
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
29
|
+
"vue/multi-word-component-names": [
|
|
30
|
+
"error",
|
|
31
|
+
{
|
|
32
|
+
"ignores": [
|
|
33
|
+
"index"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"no-console": "warn",
|
|
38
|
+
"no-debugger": "warn",
|
|
39
|
+
"prettier/prettier": [
|
|
40
|
+
"error",
|
|
41
|
+
{
|
|
42
|
+
"tabWidth": 2,
|
|
43
|
+
"singleQuote": true,
|
|
44
|
+
"semi": false,
|
|
45
|
+
"endOfLine": "auto"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
}
|
package/README.md
ADDED
package/components.d.ts
ADDED
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { PluginObject } from 'vue-demi';
|
|
2
|
+
declare const _default: import("vue/types/v3-component-public-instance").ComponentPublicInstanceConstructor<import("vue/types/v3-component-public-instance").Vue3Instance<{
|
|
3
|
+
duration: string;
|
|
4
|
+
currentDuration: string;
|
|
5
|
+
audio: string;
|
|
6
|
+
volume: number;
|
|
7
|
+
paused: boolean;
|
|
8
|
+
showVolumePanel: boolean;
|
|
9
|
+
volumeVisible: boolean;
|
|
10
|
+
volumeValue: number;
|
|
11
|
+
speed: number;
|
|
12
|
+
}, Readonly<import("vue-demi").ExtractPropTypes<{
|
|
13
|
+
audioSrc: {
|
|
14
|
+
type: StringConstructor;
|
|
15
|
+
default: string;
|
|
16
|
+
};
|
|
17
|
+
backSecond: {
|
|
18
|
+
type: NumberConstructor;
|
|
19
|
+
default: number;
|
|
20
|
+
};
|
|
21
|
+
forwardSecond: {
|
|
22
|
+
type: NumberConstructor;
|
|
23
|
+
default: number;
|
|
24
|
+
};
|
|
25
|
+
startTime: {
|
|
26
|
+
type: NumberConstructor;
|
|
27
|
+
default: number;
|
|
28
|
+
};
|
|
29
|
+
}>>, Readonly<import("vue-demi").ExtractPropTypes<{
|
|
30
|
+
audioSrc: {
|
|
31
|
+
type: StringConstructor;
|
|
32
|
+
default: string;
|
|
33
|
+
};
|
|
34
|
+
backSecond: {
|
|
35
|
+
type: NumberConstructor;
|
|
36
|
+
default: number;
|
|
37
|
+
};
|
|
38
|
+
forwardSecond: {
|
|
39
|
+
type: NumberConstructor;
|
|
40
|
+
default: number;
|
|
41
|
+
};
|
|
42
|
+
startTime: {
|
|
43
|
+
type: NumberConstructor;
|
|
44
|
+
default: number;
|
|
45
|
+
};
|
|
46
|
+
}>>, {}, {
|
|
47
|
+
audioSrc: string;
|
|
48
|
+
backSecond: number;
|
|
49
|
+
forwardSecond: number;
|
|
50
|
+
startTime: number;
|
|
51
|
+
}, true, import("vue/types/v3-component-options").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, any>> & Readonly<Readonly<import("vue-demi").ExtractPropTypes<{
|
|
52
|
+
audioSrc: {
|
|
53
|
+
type: StringConstructor;
|
|
54
|
+
default: string;
|
|
55
|
+
};
|
|
56
|
+
backSecond: {
|
|
57
|
+
type: NumberConstructor;
|
|
58
|
+
default: number;
|
|
59
|
+
};
|
|
60
|
+
forwardSecond: {
|
|
61
|
+
type: NumberConstructor;
|
|
62
|
+
default: number;
|
|
63
|
+
};
|
|
64
|
+
startTime: {
|
|
65
|
+
type: NumberConstructor;
|
|
66
|
+
default: number;
|
|
67
|
+
};
|
|
68
|
+
}>>> & import("vue-demi").ShallowUnwrapRef<{}> & {
|
|
69
|
+
duration: string;
|
|
70
|
+
currentDuration: string;
|
|
71
|
+
audio: string;
|
|
72
|
+
volume: number;
|
|
73
|
+
paused: boolean;
|
|
74
|
+
showVolumePanel: boolean;
|
|
75
|
+
volumeVisible: boolean;
|
|
76
|
+
volumeValue: number;
|
|
77
|
+
speed: number;
|
|
78
|
+
} & import("vue/types/v3-component-options").ExtractComputedReturns<{}> & import("vue-demi").ComponentCustomProperties & Readonly<import("vue-demi").ExtractPropTypes<{
|
|
79
|
+
audioSrc: {
|
|
80
|
+
type: StringConstructor;
|
|
81
|
+
default: string;
|
|
82
|
+
};
|
|
83
|
+
backSecond: {
|
|
84
|
+
type: NumberConstructor;
|
|
85
|
+
default: number;
|
|
86
|
+
};
|
|
87
|
+
forwardSecond: {
|
|
88
|
+
type: NumberConstructor;
|
|
89
|
+
default: number;
|
|
90
|
+
};
|
|
91
|
+
startTime: {
|
|
92
|
+
type: NumberConstructor;
|
|
93
|
+
default: number;
|
|
94
|
+
};
|
|
95
|
+
}>>, any, any, any, import("vue-demi").ComponentComputedOptions, import("vue-demi").ComponentMethodOptions> & import("vue/types/v3-component-options").ComponentOptionsBase<Readonly<import("vue-demi").ExtractPropTypes<{
|
|
96
|
+
audioSrc: {
|
|
97
|
+
type: StringConstructor;
|
|
98
|
+
default: string;
|
|
99
|
+
};
|
|
100
|
+
backSecond: {
|
|
101
|
+
type: NumberConstructor;
|
|
102
|
+
default: number;
|
|
103
|
+
};
|
|
104
|
+
forwardSecond: {
|
|
105
|
+
type: NumberConstructor;
|
|
106
|
+
default: number;
|
|
107
|
+
};
|
|
108
|
+
startTime: {
|
|
109
|
+
type: NumberConstructor;
|
|
110
|
+
default: number;
|
|
111
|
+
};
|
|
112
|
+
}>>, {}, {
|
|
113
|
+
duration: string;
|
|
114
|
+
currentDuration: string;
|
|
115
|
+
audio: string;
|
|
116
|
+
volume: number;
|
|
117
|
+
paused: boolean;
|
|
118
|
+
showVolumePanel: boolean;
|
|
119
|
+
volumeVisible: boolean;
|
|
120
|
+
volumeValue: number;
|
|
121
|
+
speed: number;
|
|
122
|
+
}, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, {
|
|
123
|
+
audioSrc: string;
|
|
124
|
+
backSecond: number;
|
|
125
|
+
forwardSecond: number;
|
|
126
|
+
startTime: number;
|
|
127
|
+
}> & {
|
|
128
|
+
props: {
|
|
129
|
+
audioSrc: {
|
|
130
|
+
type: StringConstructor;
|
|
131
|
+
default: string;
|
|
132
|
+
};
|
|
133
|
+
backSecond: {
|
|
134
|
+
type: NumberConstructor;
|
|
135
|
+
default: number;
|
|
136
|
+
};
|
|
137
|
+
forwardSecond: {
|
|
138
|
+
type: NumberConstructor;
|
|
139
|
+
default: number;
|
|
140
|
+
};
|
|
141
|
+
startTime: {
|
|
142
|
+
type: NumberConstructor;
|
|
143
|
+
default: number;
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
} & PluginObject<undefined>;
|
|
147
|
+
export default _default;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, any, {
|
|
2
|
+
multipleArray: string[];
|
|
3
|
+
speed: string;
|
|
4
|
+
}, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const vueDemi = require("vue-demi");
|
|
4
|
+
const vue2RuntimeHelpers = require("@94ai/vue2-runtime-helpers");
|
|
5
|
+
const elementUi = require("element-ui");
|
|
6
|
+
const __sfc_main = {};
|
|
7
|
+
__sfc_main.props = {
|
|
8
|
+
visible: [Boolean, String]
|
|
9
|
+
};
|
|
10
|
+
__sfc_main.setup = (__props, __ctx) => {
|
|
11
|
+
const emits = __ctx.emit;
|
|
12
|
+
const props = __props;
|
|
13
|
+
const reference = vueDemi.ref();
|
|
14
|
+
const popperRef = vueDemi.ref();
|
|
15
|
+
vueDemi.watch(() => props.visible, (newValue) => {
|
|
16
|
+
if (newValue) {
|
|
17
|
+
window.addEventListener("mousedown", docClick);
|
|
18
|
+
} else {
|
|
19
|
+
window.removeEventListener("mousedown", docClick);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
function docClick(e) {
|
|
23
|
+
if (popperRef.value.contains(e.target) || reference.value.contains(e.target)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
emits("update:visible", false);
|
|
27
|
+
}
|
|
28
|
+
function showPopper() {
|
|
29
|
+
emits("update:visible", true);
|
|
30
|
+
}
|
|
31
|
+
vueDemi.onUnmounted(() => {
|
|
32
|
+
emits("update:visible", false);
|
|
33
|
+
});
|
|
34
|
+
return Object.assign({
|
|
35
|
+
reference,
|
|
36
|
+
popperRef,
|
|
37
|
+
showPopper
|
|
38
|
+
}, {
|
|
39
|
+
showPopper
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
const _sfc_main$2 = __sfc_main;
|
|
43
|
+
var _sfc_render$2 = function render() {
|
|
44
|
+
var _vm = this, _c = _vm._self._c;
|
|
45
|
+
_vm._self._setupProxy;
|
|
46
|
+
return _c("div", {
|
|
47
|
+
staticClass: "nf-volume-tool",
|
|
48
|
+
class: _vm.visible ? "nf-tool-show" : "nf-tool-hide",
|
|
49
|
+
on: {
|
|
50
|
+
"click": _vm.showPopper
|
|
51
|
+
}
|
|
52
|
+
}, [_c("div", {
|
|
53
|
+
ref: "reference"
|
|
54
|
+
}, [_vm._t("reference")], 2), _c("transition", {
|
|
55
|
+
attrs: {
|
|
56
|
+
"name": "slide-fade"
|
|
57
|
+
}
|
|
58
|
+
}, [_c("div", {
|
|
59
|
+
directives: [{
|
|
60
|
+
name: "show",
|
|
61
|
+
rawName: "v-show",
|
|
62
|
+
value: _vm.visible,
|
|
63
|
+
expression: "visible"
|
|
64
|
+
}],
|
|
65
|
+
ref: "popperRef",
|
|
66
|
+
staticClass: "nf-popper"
|
|
67
|
+
}, [_vm._t("default")], 2)])], 1);
|
|
68
|
+
};
|
|
69
|
+
var _sfc_staticRenderFns$2 = [];
|
|
70
|
+
var __component__$2 = /* @__PURE__ */ vue2RuntimeHelpers.normalizeComponent(_sfc_main$2, _sfc_render$2, _sfc_staticRenderFns$2, false, null, null, null, null);
|
|
71
|
+
const volumeTool = __component__$2.exports;
|
|
72
|
+
const _sfc_main$1 = {
|
|
73
|
+
name: "more-btn",
|
|
74
|
+
components: {},
|
|
75
|
+
data() {
|
|
76
|
+
return {
|
|
77
|
+
multipleArray: ["1.0", "1.25", "1.5", "1.75", "2.0"],
|
|
78
|
+
speed: ""
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
mounted() {
|
|
82
|
+
},
|
|
83
|
+
methods: {
|
|
84
|
+
handleDown() {
|
|
85
|
+
this.$emit("down");
|
|
86
|
+
},
|
|
87
|
+
handleSpeed(speed) {
|
|
88
|
+
this.speed = speed;
|
|
89
|
+
this.$emit("speed", speed);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
var _sfc_render$1 = function render2() {
|
|
94
|
+
var _vm = this, _c = _vm._self._c;
|
|
95
|
+
return _c("div", {
|
|
96
|
+
staticClass: "more-btn-box"
|
|
97
|
+
}, [_c("el-popover", {
|
|
98
|
+
attrs: {
|
|
99
|
+
"placement": "right",
|
|
100
|
+
"popper-class": "audio-popover"
|
|
101
|
+
}
|
|
102
|
+
}, [_c("div", {
|
|
103
|
+
staticClass: "audio-btn-list"
|
|
104
|
+
}, [_c("el-popover", {
|
|
105
|
+
attrs: {
|
|
106
|
+
"placement": "right",
|
|
107
|
+
"popper-class": "audio-popover"
|
|
108
|
+
}
|
|
109
|
+
}, [_c("div", {
|
|
110
|
+
staticClass: "audio-btn-list"
|
|
111
|
+
}, _vm._l(_vm.multipleArray, function(item, index) {
|
|
112
|
+
return _c("div", {
|
|
113
|
+
key: index,
|
|
114
|
+
staticClass: "btn-item",
|
|
115
|
+
class: _vm.speed === item ? "active" : "",
|
|
116
|
+
on: {
|
|
117
|
+
"click": function($event) {
|
|
118
|
+
return _vm.handleSpeed(item);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}, [_vm._v("x " + _vm._s(item))]);
|
|
122
|
+
}), 0), _c("div", {
|
|
123
|
+
staticClass: "btn-item",
|
|
124
|
+
attrs: {
|
|
125
|
+
"slot": "reference"
|
|
126
|
+
},
|
|
127
|
+
slot: "reference"
|
|
128
|
+
}, [_vm._v("倍速")])]), _c("div", {
|
|
129
|
+
staticClass: "btn-item",
|
|
130
|
+
on: {
|
|
131
|
+
"click": _vm.handleDown
|
|
132
|
+
}
|
|
133
|
+
}, [_vm._v("下载")])], 1), _c("div", {
|
|
134
|
+
staticClass: "more-icon",
|
|
135
|
+
attrs: {
|
|
136
|
+
"slot": "reference"
|
|
137
|
+
},
|
|
138
|
+
slot: "reference"
|
|
139
|
+
}, [_c("i", {
|
|
140
|
+
staticClass: "iconfont icon-gengduo1 more-btn"
|
|
141
|
+
})])])], 1);
|
|
142
|
+
};
|
|
143
|
+
var _sfc_staticRenderFns$1 = [];
|
|
144
|
+
var __component__$1 = /* @__PURE__ */ vue2RuntimeHelpers.normalizeComponent(_sfc_main$1, _sfc_render$1, _sfc_staticRenderFns$1, false, null, null, null, null);
|
|
145
|
+
const moreBtn = __component__$1.exports;
|
|
146
|
+
const _sfc_main = {
|
|
147
|
+
name: "nf-audio",
|
|
148
|
+
components: {
|
|
149
|
+
volumeTool,
|
|
150
|
+
moreBtn
|
|
151
|
+
},
|
|
152
|
+
props: {
|
|
153
|
+
audioSrc: {
|
|
154
|
+
type: String,
|
|
155
|
+
default: ""
|
|
156
|
+
},
|
|
157
|
+
backSecond: {
|
|
158
|
+
type: Number,
|
|
159
|
+
default: 3
|
|
160
|
+
},
|
|
161
|
+
forwardSecond: {
|
|
162
|
+
type: Number,
|
|
163
|
+
default: 10
|
|
164
|
+
},
|
|
165
|
+
startTime: {
|
|
166
|
+
type: Number,
|
|
167
|
+
default: 0
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
data() {
|
|
171
|
+
return {
|
|
172
|
+
duration: "00:00",
|
|
173
|
+
currentDuration: "00:00",
|
|
174
|
+
audio: "",
|
|
175
|
+
volume: 0.8,
|
|
176
|
+
paused: true,
|
|
177
|
+
showVolumePanel: false,
|
|
178
|
+
volumeVisible: false,
|
|
179
|
+
volumeValue: 80,
|
|
180
|
+
speed: 1
|
|
181
|
+
};
|
|
182
|
+
},
|
|
183
|
+
mounted() {
|
|
184
|
+
this.audio = this.$refs.audio;
|
|
185
|
+
},
|
|
186
|
+
methods: {
|
|
187
|
+
//后退
|
|
188
|
+
handleBack() {
|
|
189
|
+
if (this.audio.currentTime > this.backSecond) {
|
|
190
|
+
this.audio.currentTime = this.audio.currentTime - this.backSecond;
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
//前进
|
|
194
|
+
handleForward() {
|
|
195
|
+
if (this.audio.duration - this.audio.currentTime > this.forwardSecond) {
|
|
196
|
+
this.audio.currentTime = this.audio.currentTime + 10;
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
//暂停或播放
|
|
200
|
+
handlePauseOrPlay() {
|
|
201
|
+
if (this.audio.readyState >= 2) {
|
|
202
|
+
this.audio.paused ? this.audio.play() : this.audio.pause();
|
|
203
|
+
this.audio.playbackRate = this.speed;
|
|
204
|
+
this.paused = !this.paused;
|
|
205
|
+
} else {
|
|
206
|
+
console.log("Audio is not ready yet.");
|
|
207
|
+
elementUi.Message.warning("音频还未加载完成");
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
//视频在可以播放时触发
|
|
211
|
+
getDuration() {
|
|
212
|
+
this.duration = this.timeFormat(this.$refs.audio.duration);
|
|
213
|
+
this.audio.volume = this.volume;
|
|
214
|
+
},
|
|
215
|
+
//将单位为秒的的时间转换成mm:ss的形式
|
|
216
|
+
timeFormat(number) {
|
|
217
|
+
let minute = parseInt(number / 60);
|
|
218
|
+
let second = parseInt(number % 60);
|
|
219
|
+
minute = minute >= 10 ? minute : "0" + minute;
|
|
220
|
+
second = second >= 10 ? second : "0" + second;
|
|
221
|
+
return minute + ":" + second;
|
|
222
|
+
},
|
|
223
|
+
//进度条发生变化时触发
|
|
224
|
+
updateTime() {
|
|
225
|
+
if (!this.$refs.progress)
|
|
226
|
+
return;
|
|
227
|
+
this.currentDuration = this.timeFormat(this.audio.currentTime);
|
|
228
|
+
if (!this.audio.paused) {
|
|
229
|
+
let MoveX = this.$refs.progress.clientWidth * (this.audio.currentTime / this.audio.duration);
|
|
230
|
+
this.$refs.currentProgress.style.width = MoveX + "px";
|
|
231
|
+
this.$refs.circle.style.left = MoveX - this.$refs.circle.clientWidth / 2 + "px";
|
|
232
|
+
this.paused = false;
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
handleAudioEnded() {
|
|
236
|
+
console.log("音频播放完毕!");
|
|
237
|
+
this.paused = true;
|
|
238
|
+
},
|
|
239
|
+
//点击进度条更新进度
|
|
240
|
+
clickProgress(e) {
|
|
241
|
+
if (this.duration === "00:00") {
|
|
242
|
+
elementUi.Message.warning("音频还未加载完成");
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
if (!this.audio.paused) {
|
|
246
|
+
this.updateProgress(e.offsetX);
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
//更新进度
|
|
250
|
+
updateProgress(MoveX) {
|
|
251
|
+
let clickProgress = MoveX / this.$refs.progress.clientWidth;
|
|
252
|
+
this.audio.currentTime = this.audio.duration * clickProgress;
|
|
253
|
+
this.$refs.currentProgress.style.width = MoveX + "px";
|
|
254
|
+
this.$refs.circle.style.left = MoveX - this.$refs.circle.clientWidth / 2 + "px";
|
|
255
|
+
},
|
|
256
|
+
//鼠标弹起
|
|
257
|
+
handleMouseup() {
|
|
258
|
+
if (this.duration === "00:00") {
|
|
259
|
+
elementUi.Message.warning("音频还未加载完成");
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
const timer = setTimeout(() => {
|
|
263
|
+
this.audio.play();
|
|
264
|
+
this.paused = false;
|
|
265
|
+
clearTimeout(timer);
|
|
266
|
+
}, 200);
|
|
267
|
+
this.$once("hook:beforeDestroy", () => {
|
|
268
|
+
clearTimeout(timer);
|
|
269
|
+
});
|
|
270
|
+
},
|
|
271
|
+
//调整进度
|
|
272
|
+
handleMousedown() {
|
|
273
|
+
this.audio.pause();
|
|
274
|
+
this.paused = true;
|
|
275
|
+
let progress = this.$refs.progress;
|
|
276
|
+
let moveMin = progress.offsetParent.offsetLeft + progress.offsetLeft;
|
|
277
|
+
let moveMax = progress.offsetParent.offsetLeft + progress.offsetLeft + progress.clientWidth;
|
|
278
|
+
let circleWidth = this.$refs.circle.clientWidth / 2;
|
|
279
|
+
let moveX = (e) => {
|
|
280
|
+
if (e.pageX >= moveMax) {
|
|
281
|
+
return;
|
|
282
|
+
} else if (e.pageX <= moveMin) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
this.$refs.circle.style.left = e.pageX - moveMin - circleWidth + "px";
|
|
286
|
+
this.updateProgress(e.pageX - moveMin);
|
|
287
|
+
};
|
|
288
|
+
document.addEventListener("mousemove", moveX);
|
|
289
|
+
document.addEventListener("mouseup", () => {
|
|
290
|
+
document.removeEventListener("mousemove", moveX);
|
|
291
|
+
});
|
|
292
|
+
},
|
|
293
|
+
rangeVolume(val) {
|
|
294
|
+
console.log(val);
|
|
295
|
+
},
|
|
296
|
+
/** 设置倍速播放 */
|
|
297
|
+
changeSpeed(command) {
|
|
298
|
+
const audioPlayer = this.$refs.audio;
|
|
299
|
+
if (audioPlayer) {
|
|
300
|
+
audioPlayer.playbackRate = command;
|
|
301
|
+
}
|
|
302
|
+
this.speed = command;
|
|
303
|
+
},
|
|
304
|
+
downRecord() {
|
|
305
|
+
this.$emit("downloadCallback");
|
|
306
|
+
},
|
|
307
|
+
calcMoveX() {
|
|
308
|
+
if (!this.audio.paused) {
|
|
309
|
+
let MoveX = this.$refs.progress.clientWidth * (this.audio.currentTime / this.audio.duration);
|
|
310
|
+
this.$refs.currentProgress.style.width = MoveX + "px";
|
|
311
|
+
this.$refs.circle.style.left = MoveX - this.$refs.circle.clientWidth / 2 + "px";
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
jumpToTime() {
|
|
315
|
+
this.audio.pause();
|
|
316
|
+
const formatStartT = this.timeFormat(this.startTime);
|
|
317
|
+
if (this.duration === "00:00") {
|
|
318
|
+
elementUi.Message.warning("音频还未加载完成");
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
if (formatStartT >= this.duration) {
|
|
322
|
+
this.audio.currentTime = this.duration;
|
|
323
|
+
this.currentDuration = this.timeFormat(this.audio.currentTime);
|
|
324
|
+
this.calcMoveX();
|
|
325
|
+
this.audio.play();
|
|
326
|
+
console.error("开始时间不能大于总时长");
|
|
327
|
+
return false;
|
|
328
|
+
} else if (formatStartT >= "00:00" && formatStartT < this.duration) {
|
|
329
|
+
this.audio.currentTime = this.startTime;
|
|
330
|
+
this.currentDuration = this.timeFormat(this.audio.currentTime);
|
|
331
|
+
this.calcMoveX();
|
|
332
|
+
this.audio.play();
|
|
333
|
+
} else {
|
|
334
|
+
this.audio.currentTime = 0;
|
|
335
|
+
this.currentDuration = this.timeFormat(this.audio.currentTime);
|
|
336
|
+
this.calcMoveX();
|
|
337
|
+
this.audio.play();
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
watch: {
|
|
342
|
+
volumeValue(val) {
|
|
343
|
+
this.volume = val / 100;
|
|
344
|
+
this.audio.volume = val / 100;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
var _sfc_render = function render3() {
|
|
349
|
+
var _vm = this, _c = _vm._self._c;
|
|
350
|
+
return _c("div", {
|
|
351
|
+
staticClass: "nf-audio-strip"
|
|
352
|
+
}, [_c("audio", {
|
|
353
|
+
directives: [{
|
|
354
|
+
name: "show",
|
|
355
|
+
rawName: "v-show",
|
|
356
|
+
value: false,
|
|
357
|
+
expression: "false"
|
|
358
|
+
}],
|
|
359
|
+
ref: "audio",
|
|
360
|
+
attrs: {
|
|
361
|
+
"controls": "",
|
|
362
|
+
"crossOrigin": "anonymous",
|
|
363
|
+
"src": _vm.audioSrc
|
|
364
|
+
},
|
|
365
|
+
on: {
|
|
366
|
+
"canplay": _vm.getDuration,
|
|
367
|
+
"timeupdate": _vm.updateTime,
|
|
368
|
+
"ended": _vm.handleAudioEnded
|
|
369
|
+
}
|
|
370
|
+
}), _c("div", {
|
|
371
|
+
staticClass: "nf-fast"
|
|
372
|
+
}, [_c("i", {
|
|
373
|
+
staticClass: "iconfont icon-zanting1 nf-fast-icon",
|
|
374
|
+
on: {
|
|
375
|
+
"click": _vm.jumpToTime
|
|
376
|
+
}
|
|
377
|
+
})]), _c("div", {
|
|
378
|
+
staticClass: "nf-audio"
|
|
379
|
+
}, [_c("div", {
|
|
380
|
+
staticClass: "play",
|
|
381
|
+
on: {
|
|
382
|
+
"click": _vm.handlePauseOrPlay
|
|
383
|
+
}
|
|
384
|
+
}, [_c("i", {
|
|
385
|
+
directives: [{
|
|
386
|
+
name: "show",
|
|
387
|
+
rawName: "v-show",
|
|
388
|
+
value: !_vm.paused,
|
|
389
|
+
expression: "!paused"
|
|
390
|
+
}],
|
|
391
|
+
staticClass: "iconfont icon-zanting2 pause-icon"
|
|
392
|
+
}), _c("i", {
|
|
393
|
+
directives: [{
|
|
394
|
+
name: "show",
|
|
395
|
+
rawName: "v-show",
|
|
396
|
+
value: _vm.paused,
|
|
397
|
+
expression: "paused"
|
|
398
|
+
}],
|
|
399
|
+
staticClass: "iconfont icon-bofang1 play-icon"
|
|
400
|
+
})]), _c("div", {
|
|
401
|
+
staticClass: "time"
|
|
402
|
+
}, [_c("span", {
|
|
403
|
+
staticClass: "startTime"
|
|
404
|
+
}, [_vm._v(_vm._s(_vm.currentDuration))]), _vm._v("/ "), _c("span", {
|
|
405
|
+
staticClass: "endTime"
|
|
406
|
+
}, [_vm._v(_vm._s(_vm.duration))])]), _c("div", {
|
|
407
|
+
ref: "progress",
|
|
408
|
+
staticClass: "progress",
|
|
409
|
+
on: {
|
|
410
|
+
"click": _vm.clickProgress,
|
|
411
|
+
"mouseup": _vm.handleMouseup
|
|
412
|
+
}
|
|
413
|
+
}, [_c("div", {
|
|
414
|
+
ref: "currentProgress",
|
|
415
|
+
staticClass: "currentProgress"
|
|
416
|
+
}, [_c("span", {
|
|
417
|
+
ref: "circle",
|
|
418
|
+
staticClass: "circle",
|
|
419
|
+
on: {
|
|
420
|
+
"mousedown": _vm.handleMousedown
|
|
421
|
+
}
|
|
422
|
+
})])]), _c("div", {
|
|
423
|
+
staticClass: "nf-volume-panel"
|
|
424
|
+
}, [_c("volumeTool", {
|
|
425
|
+
attrs: {
|
|
426
|
+
"visible": _vm.volumeVisible
|
|
427
|
+
},
|
|
428
|
+
on: {
|
|
429
|
+
"update:visible": function($event) {
|
|
430
|
+
_vm.volumeVisible = $event;
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
scopedSlots: _vm._u([{
|
|
434
|
+
key: "reference",
|
|
435
|
+
fn: function() {
|
|
436
|
+
return [_vm.volume == 0 ? _c("i", {
|
|
437
|
+
staticClass: "iconfont icon-yinliang_guanbi volume-mute"
|
|
438
|
+
}) : _c("i", {
|
|
439
|
+
staticClass: "iconfont icon-yinliang_kaiqi volume"
|
|
440
|
+
})];
|
|
441
|
+
},
|
|
442
|
+
proxy: true
|
|
443
|
+
}])
|
|
444
|
+
}, [_c("el-slider", {
|
|
445
|
+
class: _vm.volumeValue === 0 ? "volume-mute-slider" : "volume-phonic",
|
|
446
|
+
attrs: {
|
|
447
|
+
"vertical": "",
|
|
448
|
+
"min": 0,
|
|
449
|
+
"max": 100,
|
|
450
|
+
"show-tooltip": _vm.volumeVisible,
|
|
451
|
+
"height": "60px"
|
|
452
|
+
},
|
|
453
|
+
on: {
|
|
454
|
+
"change": _vm.rangeVolume
|
|
455
|
+
},
|
|
456
|
+
model: {
|
|
457
|
+
value: _vm.volumeValue,
|
|
458
|
+
callback: function($$v) {
|
|
459
|
+
_vm.volumeValue = $$v;
|
|
460
|
+
},
|
|
461
|
+
expression: "volumeValue"
|
|
462
|
+
}
|
|
463
|
+
})], 1)], 1), _c("div", {
|
|
464
|
+
staticClass: "option"
|
|
465
|
+
}, [_c("moreBtn", {
|
|
466
|
+
on: {
|
|
467
|
+
"down": function($event) {
|
|
468
|
+
return _vm.downRecord();
|
|
469
|
+
},
|
|
470
|
+
"speed": _vm.changeSpeed
|
|
471
|
+
}
|
|
472
|
+
})], 1)])]);
|
|
473
|
+
};
|
|
474
|
+
var _sfc_staticRenderFns = [];
|
|
475
|
+
var __component__ = /* @__PURE__ */ vue2RuntimeHelpers.normalizeComponent(_sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, null, null, null);
|
|
476
|
+
const NfAudio = __component__.exports;
|
|
477
|
+
NfAudio.install = (app) => {
|
|
478
|
+
app.component("nf-audio", NfAudio);
|
|
479
|
+
};
|
|
480
|
+
exports.default = NfAudio;
|