@94ai/nf-audio 3.3.55 → 3.3.60
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 +65 -5
- package/lib/nf-audio.esm-bundler.js +65 -5
- package/package/nf-audio.vue +68 -8
- package/package.json +3 -3
package/lib/nf-audio.cjs.js
CHANGED
|
@@ -81,10 +81,19 @@ const _sfc_main = {
|
|
|
81
81
|
initVolumnValue: {
|
|
82
82
|
type: Number,
|
|
83
83
|
default: 0.8
|
|
84
|
+
},
|
|
85
|
+
betweenStart: {
|
|
86
|
+
type: Number,
|
|
87
|
+
default: 0
|
|
88
|
+
},
|
|
89
|
+
betweenEnd: {
|
|
90
|
+
type: Number,
|
|
91
|
+
default: 0
|
|
84
92
|
}
|
|
85
93
|
},
|
|
86
94
|
data() {
|
|
87
95
|
return {
|
|
96
|
+
betweenPlaying: false,
|
|
88
97
|
// 播放还是暂停
|
|
89
98
|
paused: true,
|
|
90
99
|
moveMin: 0,
|
|
@@ -110,11 +119,20 @@ const _sfc_main = {
|
|
|
110
119
|
}
|
|
111
120
|
},
|
|
112
121
|
mounted() {
|
|
113
|
-
this.speed = this.initSpeedValue;
|
|
114
122
|
this.volume = this.initVolumnValue;
|
|
115
123
|
this.volumeValue = this.initVolumnValue * 100;
|
|
124
|
+
this.syncSpeed();
|
|
116
125
|
},
|
|
117
126
|
methods: {
|
|
127
|
+
locationToTime(time) {
|
|
128
|
+
this.betweenPlaying = false;
|
|
129
|
+
this.jumpToTime(time);
|
|
130
|
+
},
|
|
131
|
+
syncSpeed() {
|
|
132
|
+
if (this.speed != this.initSpeedValue) {
|
|
133
|
+
this.speed = this.initSpeedValue;
|
|
134
|
+
}
|
|
135
|
+
},
|
|
118
136
|
docClick(e) {
|
|
119
137
|
if (this.$refs.popperRef.contains(e.target) || this.$refs.reference.contains(e.target)) {
|
|
120
138
|
return;
|
|
@@ -130,9 +148,13 @@ const _sfc_main = {
|
|
|
130
148
|
handleBack() {
|
|
131
149
|
if (this.audio.currentTime - this.backSecond <= 0) {
|
|
132
150
|
this.jumpToTime(0);
|
|
151
|
+
this.betweenPlaying = false;
|
|
152
|
+
this.$emit("back", 0);
|
|
133
153
|
} else {
|
|
134
154
|
if (this.audio.currentTime < this.audio.duration) {
|
|
135
155
|
this.jumpToTime(this.audio.currentTime - this.backSecond);
|
|
156
|
+
this.betweenPlaying = false;
|
|
157
|
+
this.$emit("back", this.audio.currentTime - this.backSecond);
|
|
136
158
|
}
|
|
137
159
|
}
|
|
138
160
|
},
|
|
@@ -140,9 +162,13 @@ const _sfc_main = {
|
|
|
140
162
|
handleForward() {
|
|
141
163
|
if (this.audio.currentTime + this.forwardSecond <= this.audio.duration) {
|
|
142
164
|
this.jumpToTime(this.audio.currentTime + this.forwardSecond);
|
|
165
|
+
this.betweenPlaying = false;
|
|
166
|
+
this.$emit("forward", this.audio.currentTime + this.forwardSecond);
|
|
143
167
|
} else {
|
|
144
168
|
if (this.audio.currentTime < this.audio.duration) {
|
|
145
169
|
this.jumpToTime(this.audio.duration);
|
|
170
|
+
this.betweenPlaying = false;
|
|
171
|
+
this.$emit("forward", this.audio.duration);
|
|
146
172
|
}
|
|
147
173
|
}
|
|
148
174
|
},
|
|
@@ -153,12 +179,25 @@ const _sfc_main = {
|
|
|
153
179
|
this.audio.paused ? this.audio.play() : this.audio.pause();
|
|
154
180
|
this.audio.playbackRate = this.speed;
|
|
155
181
|
this.paused = !this.paused;
|
|
182
|
+
this.betweenPlaying = false;
|
|
183
|
+
this.$emit("pauseOrPlay", this.paused);
|
|
156
184
|
} else {
|
|
157
185
|
console.log("Audio is not ready yet.");
|
|
158
186
|
nfMessage.Message.warning(this.unloadTip);
|
|
187
|
+
this.paused = true;
|
|
159
188
|
}
|
|
160
189
|
}
|
|
161
190
|
},
|
|
191
|
+
pause() {
|
|
192
|
+
this.audio.pause();
|
|
193
|
+
this.paused = true;
|
|
194
|
+
this.betweenPlaying = false;
|
|
195
|
+
},
|
|
196
|
+
play() {
|
|
197
|
+
this.audio.play();
|
|
198
|
+
this.paused = false;
|
|
199
|
+
this.betweenPlaying = false;
|
|
200
|
+
},
|
|
162
201
|
//视频在可以播放时触发
|
|
163
202
|
getDuration() {
|
|
164
203
|
this.totalTime = timeFormat(this.audio.duration);
|
|
@@ -174,6 +213,20 @@ const _sfc_main = {
|
|
|
174
213
|
this.$refs.progressCurrent.style.width = MoveX + "px";
|
|
175
214
|
this.$refs.progressBar.style.left = MoveX - this.$refs.progressBar.clientWidth / 2 + "px";
|
|
176
215
|
this.paused = false;
|
|
216
|
+
if (this.betweenPlaying) {
|
|
217
|
+
if (this.betweenStart && this.betweenEnd) {
|
|
218
|
+
console.log(this.audio.currentTime, "this.audio.currentTime");
|
|
219
|
+
if (this.audio.currentTime >= this.betweenEnd) {
|
|
220
|
+
this.pause();
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
betweenPlay() {
|
|
227
|
+
if (!this.disabled) {
|
|
228
|
+
this.betweenPlaying = true;
|
|
229
|
+
this.jumpToTime(this.betweenStart);
|
|
177
230
|
}
|
|
178
231
|
},
|
|
179
232
|
handleAudioEnded() {
|
|
@@ -186,10 +239,12 @@ const _sfc_main = {
|
|
|
186
239
|
if (!this.disabled) {
|
|
187
240
|
if (this.audio.duration === 0) {
|
|
188
241
|
nfMessage.Message.warning(this.unloadTip);
|
|
242
|
+
this.paused = true;
|
|
189
243
|
return false;
|
|
190
244
|
}
|
|
191
245
|
if (!this.audio.paused) {
|
|
192
246
|
this.updateProgress(e.offsetX);
|
|
247
|
+
this.$emit("updateProgress", e.offsetX);
|
|
193
248
|
}
|
|
194
249
|
}
|
|
195
250
|
},
|
|
@@ -205,6 +260,7 @@ const _sfc_main = {
|
|
|
205
260
|
if (!this.disabled) {
|
|
206
261
|
if (this.audio.duration === 0) {
|
|
207
262
|
nfMessage.Message.warning(this.unloadTip);
|
|
263
|
+
this.paused = true;
|
|
208
264
|
return false;
|
|
209
265
|
}
|
|
210
266
|
this.audio.play();
|
|
@@ -265,6 +321,7 @@ const _sfc_main = {
|
|
|
265
321
|
this.audio.pause();
|
|
266
322
|
if (this.audio.duration === 0) {
|
|
267
323
|
nfMessage.Message.warning(this.unloadTip);
|
|
324
|
+
this.paused = true;
|
|
268
325
|
return false;
|
|
269
326
|
}
|
|
270
327
|
if (time >= this.audio.duration) {
|
|
@@ -287,13 +344,16 @@ const _sfc_main = {
|
|
|
287
344
|
this.calcMoveX();
|
|
288
345
|
this.audio.play();
|
|
289
346
|
}
|
|
347
|
+
this.$emit("jumpToTime", time);
|
|
290
348
|
}
|
|
291
349
|
}
|
|
292
350
|
},
|
|
293
351
|
watch: {
|
|
294
352
|
initSpeedValue: {
|
|
295
353
|
handle() {
|
|
296
|
-
this.speed
|
|
354
|
+
if (this.speed != this.initSpeedValue) {
|
|
355
|
+
this.speed = this.initSpeedValue;
|
|
356
|
+
}
|
|
297
357
|
}
|
|
298
358
|
},
|
|
299
359
|
initVolumnValue: {
|
|
@@ -342,14 +402,14 @@ var _sfc_render = function render() {
|
|
|
342
402
|
"timeupdate": _vm.updateTime,
|
|
343
403
|
"ended": _vm.handleAudioEnded
|
|
344
404
|
}
|
|
345
|
-
}), _vm.jumpTime ? _vm._t("jump", function() {
|
|
405
|
+
}), typeof _vm.jumpTime === "undefined" ? _vm._t("jump", function() {
|
|
346
406
|
return [_c("div", {
|
|
347
407
|
staticClass: "nf-audio-fast"
|
|
348
408
|
}, [_c("i", {
|
|
349
409
|
staticClass: "iconfont icon-zanting1 nf-audio-fast-icon",
|
|
350
410
|
on: {
|
|
351
411
|
"click": function($event) {
|
|
352
|
-
return _vm.
|
|
412
|
+
return _vm.locationToTime(_vm.jumpTime);
|
|
353
413
|
}
|
|
354
414
|
}
|
|
355
415
|
})])];
|
|
@@ -549,7 +609,7 @@ var _sfc_render = function render() {
|
|
|
549
609
|
return _c("div", {
|
|
550
610
|
key: index,
|
|
551
611
|
staticClass: "nf-audio-btn-item",
|
|
552
|
-
class: _vm.speed
|
|
612
|
+
class: _vm.speed == item ? "active" : "",
|
|
553
613
|
on: {
|
|
554
614
|
"click": function($event) {
|
|
555
615
|
return _vm.changeSpeed(item);
|
|
@@ -79,10 +79,19 @@ const _sfc_main = {
|
|
|
79
79
|
initVolumnValue: {
|
|
80
80
|
type: Number,
|
|
81
81
|
default: 0.8
|
|
82
|
+
},
|
|
83
|
+
betweenStart: {
|
|
84
|
+
type: Number,
|
|
85
|
+
default: 0
|
|
86
|
+
},
|
|
87
|
+
betweenEnd: {
|
|
88
|
+
type: Number,
|
|
89
|
+
default: 0
|
|
82
90
|
}
|
|
83
91
|
},
|
|
84
92
|
data() {
|
|
85
93
|
return {
|
|
94
|
+
betweenPlaying: false,
|
|
86
95
|
// 播放还是暂停
|
|
87
96
|
paused: true,
|
|
88
97
|
moveMin: 0,
|
|
@@ -108,11 +117,20 @@ const _sfc_main = {
|
|
|
108
117
|
}
|
|
109
118
|
},
|
|
110
119
|
mounted() {
|
|
111
|
-
this.speed = this.initSpeedValue;
|
|
112
120
|
this.volume = this.initVolumnValue;
|
|
113
121
|
this.volumeValue = this.initVolumnValue * 100;
|
|
122
|
+
this.syncSpeed();
|
|
114
123
|
},
|
|
115
124
|
methods: {
|
|
125
|
+
locationToTime(time) {
|
|
126
|
+
this.betweenPlaying = false;
|
|
127
|
+
this.jumpToTime(time);
|
|
128
|
+
},
|
|
129
|
+
syncSpeed() {
|
|
130
|
+
if (this.speed != this.initSpeedValue) {
|
|
131
|
+
this.speed = this.initSpeedValue;
|
|
132
|
+
}
|
|
133
|
+
},
|
|
116
134
|
docClick(e) {
|
|
117
135
|
if (this.$refs.popperRef.contains(e.target) || this.$refs.reference.contains(e.target)) {
|
|
118
136
|
return;
|
|
@@ -128,9 +146,13 @@ const _sfc_main = {
|
|
|
128
146
|
handleBack() {
|
|
129
147
|
if (this.audio.currentTime - this.backSecond <= 0) {
|
|
130
148
|
this.jumpToTime(0);
|
|
149
|
+
this.betweenPlaying = false;
|
|
150
|
+
this.$emit("back", 0);
|
|
131
151
|
} else {
|
|
132
152
|
if (this.audio.currentTime < this.audio.duration) {
|
|
133
153
|
this.jumpToTime(this.audio.currentTime - this.backSecond);
|
|
154
|
+
this.betweenPlaying = false;
|
|
155
|
+
this.$emit("back", this.audio.currentTime - this.backSecond);
|
|
134
156
|
}
|
|
135
157
|
}
|
|
136
158
|
},
|
|
@@ -138,9 +160,13 @@ const _sfc_main = {
|
|
|
138
160
|
handleForward() {
|
|
139
161
|
if (this.audio.currentTime + this.forwardSecond <= this.audio.duration) {
|
|
140
162
|
this.jumpToTime(this.audio.currentTime + this.forwardSecond);
|
|
163
|
+
this.betweenPlaying = false;
|
|
164
|
+
this.$emit("forward", this.audio.currentTime + this.forwardSecond);
|
|
141
165
|
} else {
|
|
142
166
|
if (this.audio.currentTime < this.audio.duration) {
|
|
143
167
|
this.jumpToTime(this.audio.duration);
|
|
168
|
+
this.betweenPlaying = false;
|
|
169
|
+
this.$emit("forward", this.audio.duration);
|
|
144
170
|
}
|
|
145
171
|
}
|
|
146
172
|
},
|
|
@@ -151,12 +177,25 @@ const _sfc_main = {
|
|
|
151
177
|
this.audio.paused ? this.audio.play() : this.audio.pause();
|
|
152
178
|
this.audio.playbackRate = this.speed;
|
|
153
179
|
this.paused = !this.paused;
|
|
180
|
+
this.betweenPlaying = false;
|
|
181
|
+
this.$emit("pauseOrPlay", this.paused);
|
|
154
182
|
} else {
|
|
155
183
|
console.log("Audio is not ready yet.");
|
|
156
184
|
Message.warning(this.unloadTip);
|
|
185
|
+
this.paused = true;
|
|
157
186
|
}
|
|
158
187
|
}
|
|
159
188
|
},
|
|
189
|
+
pause() {
|
|
190
|
+
this.audio.pause();
|
|
191
|
+
this.paused = true;
|
|
192
|
+
this.betweenPlaying = false;
|
|
193
|
+
},
|
|
194
|
+
play() {
|
|
195
|
+
this.audio.play();
|
|
196
|
+
this.paused = false;
|
|
197
|
+
this.betweenPlaying = false;
|
|
198
|
+
},
|
|
160
199
|
//视频在可以播放时触发
|
|
161
200
|
getDuration() {
|
|
162
201
|
this.totalTime = timeFormat(this.audio.duration);
|
|
@@ -172,6 +211,20 @@ const _sfc_main = {
|
|
|
172
211
|
this.$refs.progressCurrent.style.width = MoveX + "px";
|
|
173
212
|
this.$refs.progressBar.style.left = MoveX - this.$refs.progressBar.clientWidth / 2 + "px";
|
|
174
213
|
this.paused = false;
|
|
214
|
+
if (this.betweenPlaying) {
|
|
215
|
+
if (this.betweenStart && this.betweenEnd) {
|
|
216
|
+
console.log(this.audio.currentTime, "this.audio.currentTime");
|
|
217
|
+
if (this.audio.currentTime >= this.betweenEnd) {
|
|
218
|
+
this.pause();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
betweenPlay() {
|
|
225
|
+
if (!this.disabled) {
|
|
226
|
+
this.betweenPlaying = true;
|
|
227
|
+
this.jumpToTime(this.betweenStart);
|
|
175
228
|
}
|
|
176
229
|
},
|
|
177
230
|
handleAudioEnded() {
|
|
@@ -184,10 +237,12 @@ const _sfc_main = {
|
|
|
184
237
|
if (!this.disabled) {
|
|
185
238
|
if (this.audio.duration === 0) {
|
|
186
239
|
Message.warning(this.unloadTip);
|
|
240
|
+
this.paused = true;
|
|
187
241
|
return false;
|
|
188
242
|
}
|
|
189
243
|
if (!this.audio.paused) {
|
|
190
244
|
this.updateProgress(e.offsetX);
|
|
245
|
+
this.$emit("updateProgress", e.offsetX);
|
|
191
246
|
}
|
|
192
247
|
}
|
|
193
248
|
},
|
|
@@ -203,6 +258,7 @@ const _sfc_main = {
|
|
|
203
258
|
if (!this.disabled) {
|
|
204
259
|
if (this.audio.duration === 0) {
|
|
205
260
|
Message.warning(this.unloadTip);
|
|
261
|
+
this.paused = true;
|
|
206
262
|
return false;
|
|
207
263
|
}
|
|
208
264
|
this.audio.play();
|
|
@@ -263,6 +319,7 @@ const _sfc_main = {
|
|
|
263
319
|
this.audio.pause();
|
|
264
320
|
if (this.audio.duration === 0) {
|
|
265
321
|
Message.warning(this.unloadTip);
|
|
322
|
+
this.paused = true;
|
|
266
323
|
return false;
|
|
267
324
|
}
|
|
268
325
|
if (time >= this.audio.duration) {
|
|
@@ -285,13 +342,16 @@ const _sfc_main = {
|
|
|
285
342
|
this.calcMoveX();
|
|
286
343
|
this.audio.play();
|
|
287
344
|
}
|
|
345
|
+
this.$emit("jumpToTime", time);
|
|
288
346
|
}
|
|
289
347
|
}
|
|
290
348
|
},
|
|
291
349
|
watch: {
|
|
292
350
|
initSpeedValue: {
|
|
293
351
|
handle() {
|
|
294
|
-
this.speed
|
|
352
|
+
if (this.speed != this.initSpeedValue) {
|
|
353
|
+
this.speed = this.initSpeedValue;
|
|
354
|
+
}
|
|
295
355
|
}
|
|
296
356
|
},
|
|
297
357
|
initVolumnValue: {
|
|
@@ -340,14 +400,14 @@ var _sfc_render = function render() {
|
|
|
340
400
|
"timeupdate": _vm.updateTime,
|
|
341
401
|
"ended": _vm.handleAudioEnded
|
|
342
402
|
}
|
|
343
|
-
}), _vm.jumpTime ? _vm._t("jump", function() {
|
|
403
|
+
}), typeof _vm.jumpTime === "undefined" ? _vm._t("jump", function() {
|
|
344
404
|
return [_c("div", {
|
|
345
405
|
staticClass: "nf-audio-fast"
|
|
346
406
|
}, [_c("i", {
|
|
347
407
|
staticClass: "iconfont icon-zanting1 nf-audio-fast-icon",
|
|
348
408
|
on: {
|
|
349
409
|
"click": function($event) {
|
|
350
|
-
return _vm.
|
|
410
|
+
return _vm.locationToTime(_vm.jumpTime);
|
|
351
411
|
}
|
|
352
412
|
}
|
|
353
413
|
})])];
|
|
@@ -547,7 +607,7 @@ var _sfc_render = function render() {
|
|
|
547
607
|
return _c("div", {
|
|
548
608
|
key: index,
|
|
549
609
|
staticClass: "nf-audio-btn-item",
|
|
550
|
-
class: _vm.speed
|
|
610
|
+
class: _vm.speed == item ? "active" : "",
|
|
551
611
|
on: {
|
|
552
612
|
"click": function($event) {
|
|
553
613
|
return _vm.changeSpeed(item);
|
package/package/nf-audio.vue
CHANGED
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
/>
|
|
17
17
|
|
|
18
18
|
<!-- 跳帧 -->
|
|
19
|
-
<slot name="jump" v-if="jumpTime">
|
|
19
|
+
<slot name="jump" v-if="typeof jumpTime === 'undefined'">
|
|
20
20
|
<div class="nf-audio-fast">
|
|
21
21
|
<i class="iconfont icon-zanting1 nf-audio-fast-icon"
|
|
22
|
-
@click="
|
|
22
|
+
@click="locationToTime(jumpTime)"
|
|
23
23
|
/>
|
|
24
24
|
</div>
|
|
25
25
|
</slot>
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
<div v-for="(item,index) in multipleArray"
|
|
137
137
|
:key="index"
|
|
138
138
|
class="nf-audio-btn-item"
|
|
139
|
-
:class="speed
|
|
139
|
+
:class="speed==item?'active':''"
|
|
140
140
|
@click="changeSpeed(item)"
|
|
141
141
|
>
|
|
142
142
|
{{ speedPreDesc }}{{ item }}
|
|
@@ -237,10 +237,19 @@ export default {
|
|
|
237
237
|
initVolumnValue: {
|
|
238
238
|
type: Number,
|
|
239
239
|
default: 0.8
|
|
240
|
+
},
|
|
241
|
+
betweenStart: {
|
|
242
|
+
type: Number,
|
|
243
|
+
default: 0
|
|
244
|
+
},
|
|
245
|
+
betweenEnd: {
|
|
246
|
+
type: Number,
|
|
247
|
+
default: 0
|
|
240
248
|
}
|
|
241
249
|
},
|
|
242
250
|
data() {
|
|
243
251
|
return {
|
|
252
|
+
betweenPlaying: false,
|
|
244
253
|
// 播放还是暂停
|
|
245
254
|
paused: true,
|
|
246
255
|
moveMin: 0,
|
|
@@ -270,11 +279,20 @@ export default {
|
|
|
270
279
|
}
|
|
271
280
|
},
|
|
272
281
|
mounted() {
|
|
273
|
-
this.speed = this.initSpeedValue
|
|
274
282
|
this.volume = this.initVolumnValue
|
|
275
283
|
this.volumeValue = this.initVolumnValue * 100
|
|
284
|
+
this.syncSpeed()
|
|
276
285
|
},
|
|
277
286
|
methods: {
|
|
287
|
+
locationToTime(time) {
|
|
288
|
+
this.betweenPlaying = false
|
|
289
|
+
this.jumpToTime(time)
|
|
290
|
+
},
|
|
291
|
+
syncSpeed() {
|
|
292
|
+
if (this.speed != this.initSpeedValue) {
|
|
293
|
+
this.speed = this.initSpeedValue
|
|
294
|
+
}
|
|
295
|
+
},
|
|
278
296
|
docClick(e) {
|
|
279
297
|
//如果点击的是音量 或者 是音量面板 则 不隐藏音量面板
|
|
280
298
|
if (this.$refs.popperRef.contains(e.target) || this.$refs.reference.contains(e.target)) {
|
|
@@ -291,9 +309,13 @@ export default {
|
|
|
291
309
|
handleBack() {
|
|
292
310
|
if (this.audio.currentTime - this.backSecond <= 0) {
|
|
293
311
|
this.jumpToTime(0)
|
|
312
|
+
this.betweenPlaying = false
|
|
313
|
+
this.$emit('back', 0)
|
|
294
314
|
} else {
|
|
295
315
|
if (this.audio.currentTime < this.audio.duration) {
|
|
296
316
|
this.jumpToTime(this.audio.currentTime - this.backSecond)
|
|
317
|
+
this.betweenPlaying = false
|
|
318
|
+
this.$emit('back', this.audio.currentTime - this.backSecond)
|
|
297
319
|
}
|
|
298
320
|
}
|
|
299
321
|
},
|
|
@@ -301,9 +323,13 @@ export default {
|
|
|
301
323
|
handleForward() {
|
|
302
324
|
if (this.audio.currentTime + this.forwardSecond <= this.audio.duration) {
|
|
303
325
|
this.jumpToTime(this.audio.currentTime + this.forwardSecond)
|
|
326
|
+
this.betweenPlaying = false
|
|
327
|
+
this.$emit('forward', this.audio.currentTime + this.forwardSecond)
|
|
304
328
|
} else {
|
|
305
329
|
if (this.audio.currentTime < this.audio.duration) {
|
|
306
330
|
this.jumpToTime(this.audio.duration)
|
|
331
|
+
this.betweenPlaying = false
|
|
332
|
+
this.$emit('forward', this.audio.duration)
|
|
307
333
|
}
|
|
308
334
|
}
|
|
309
335
|
},
|
|
@@ -315,12 +341,25 @@ export default {
|
|
|
315
341
|
this.audio.paused ? this.audio.play() : this.audio.pause()
|
|
316
342
|
this.audio.playbackRate = this.speed
|
|
317
343
|
this.paused = !this.paused
|
|
344
|
+
this.betweenPlaying = false
|
|
345
|
+
this.$emit('pauseOrPlay', this.paused)
|
|
318
346
|
} else {
|
|
319
347
|
console.log('Audio is not ready yet.')
|
|
320
348
|
Message.warning(this.unloadTip)
|
|
349
|
+
this.paused = true
|
|
321
350
|
}
|
|
322
351
|
}
|
|
323
352
|
},
|
|
353
|
+
pause() {
|
|
354
|
+
this.audio.pause()
|
|
355
|
+
this.paused = true
|
|
356
|
+
this.betweenPlaying = false
|
|
357
|
+
},
|
|
358
|
+
play() {
|
|
359
|
+
this.audio.play()
|
|
360
|
+
this.paused = false
|
|
361
|
+
this.betweenPlaying = false
|
|
362
|
+
},
|
|
324
363
|
//视频在可以播放时触发
|
|
325
364
|
getDuration() {
|
|
326
365
|
this.totalTime = timeFormat(this.audio.duration)
|
|
@@ -330,15 +369,29 @@ export default {
|
|
|
330
369
|
//进度条发生变化时触发
|
|
331
370
|
updateTime() {
|
|
332
371
|
if (!this.$refs.progressContainer) return
|
|
372
|
+
// 设置当前时间
|
|
333
373
|
this.currentTime = timeFormat(this.audio.currentTime)
|
|
334
|
-
|
|
374
|
+
|
|
335
375
|
if (!this.audio.paused) {
|
|
336
|
-
// 设置当前时间
|
|
337
376
|
let MoveX = this.$refs.progressContainer.clientWidth * (this.audio.currentTime / this.audio.duration)
|
|
338
|
-
|
|
377
|
+
// 播放时更新距离
|
|
339
378
|
this.$refs.progressCurrent.style.width = MoveX + 'px'
|
|
340
379
|
this.$refs.progressBar.style.left = MoveX - (this.$refs.progressBar.clientWidth / 2) + 'px'
|
|
341
380
|
this.paused = false
|
|
381
|
+
if (this.betweenPlaying) {
|
|
382
|
+
if (this.betweenStart && this.betweenEnd) {
|
|
383
|
+
console.log(this.audio.currentTime, 'this.audio.currentTime')
|
|
384
|
+
if (this.audio.currentTime >= this.betweenEnd) {
|
|
385
|
+
this.pause()
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
betweenPlay() {
|
|
392
|
+
if (!this.disabled) {
|
|
393
|
+
this.betweenPlaying = true
|
|
394
|
+
this.jumpToTime(this.betweenStart)
|
|
342
395
|
}
|
|
343
396
|
},
|
|
344
397
|
handleAudioEnded() {
|
|
@@ -351,11 +404,13 @@ export default {
|
|
|
351
404
|
if (!this.disabled) {
|
|
352
405
|
if (this.audio.duration === 0) {
|
|
353
406
|
Message.warning(this.unloadTip)
|
|
407
|
+
this.paused = true
|
|
354
408
|
return false
|
|
355
409
|
}
|
|
356
410
|
//如果不是正在移动 和 没有暂停播放就执行
|
|
357
411
|
if (!this.audio.paused) {
|
|
358
412
|
this.updateProgress(e.offsetX)
|
|
413
|
+
this.$emit('updateProgress', e.offsetX)
|
|
359
414
|
}
|
|
360
415
|
}
|
|
361
416
|
},
|
|
@@ -374,6 +429,7 @@ export default {
|
|
|
374
429
|
if (!this.disabled) {
|
|
375
430
|
if (this.audio.duration === 0) {
|
|
376
431
|
Message.warning(this.unloadTip)
|
|
432
|
+
this.paused = true
|
|
377
433
|
return false
|
|
378
434
|
}
|
|
379
435
|
this.audio.play()
|
|
@@ -441,6 +497,7 @@ export default {
|
|
|
441
497
|
this.audio.pause()
|
|
442
498
|
if (this.audio.duration === 0) {
|
|
443
499
|
Message.warning(this.unloadTip)
|
|
500
|
+
this.paused = true
|
|
444
501
|
return false
|
|
445
502
|
}
|
|
446
503
|
if (time >= this.audio.duration) {
|
|
@@ -463,13 +520,16 @@ export default {
|
|
|
463
520
|
this.calcMoveX()
|
|
464
521
|
this.audio.play()
|
|
465
522
|
}
|
|
523
|
+
this.$emit('jumpToTime', time)
|
|
466
524
|
}
|
|
467
525
|
}
|
|
468
526
|
},
|
|
469
527
|
watch: {
|
|
470
528
|
initSpeedValue: {
|
|
471
529
|
handle() {
|
|
472
|
-
this.speed
|
|
530
|
+
if (this.speed != this.initSpeedValue) {
|
|
531
|
+
this.speed = this.initSpeedValue
|
|
532
|
+
}
|
|
473
533
|
}
|
|
474
534
|
},
|
|
475
535
|
initVolumnValue: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@94ai/nf-audio",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.60",
|
|
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.60",
|
|
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": "29cda3344f971577a22be62897195114e3cdd761"
|
|
34
34
|
}
|