@94ai/nf-audio 3.3.51 → 3.3.53

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/index.d.ts CHANGED
@@ -10,6 +10,10 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
10
10
  volumeValue: number;
11
11
  speed: number;
12
12
  }, Readonly<import("vue-demi").ExtractPropTypes<{
13
+ disabled: {
14
+ type: BooleanConstructor;
15
+ default: boolean;
16
+ };
13
17
  showMoreBtn: {
14
18
  type: BooleanConstructor;
15
19
  default: boolean;
@@ -35,6 +39,10 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
35
39
  default: number;
36
40
  };
37
41
  }>>, Readonly<import("vue-demi").ExtractPropTypes<{
42
+ disabled: {
43
+ type: BooleanConstructor;
44
+ default: boolean;
45
+ };
38
46
  showMoreBtn: {
39
47
  type: BooleanConstructor;
40
48
  default: boolean;
@@ -60,6 +68,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
60
68
  default: number;
61
69
  };
62
70
  }>>, {}, {
71
+ disabled: boolean;
63
72
  showMoreBtn: boolean;
64
73
  showJumpToTime: boolean;
65
74
  audioSrc: string;
@@ -67,6 +76,10 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
67
76
  forwardSecond: number;
68
77
  startTime: number;
69
78
  }, true, import("vue/types/v3-component-options").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, any>> & Readonly<Readonly<import("vue-demi").ExtractPropTypes<{
79
+ disabled: {
80
+ type: BooleanConstructor;
81
+ default: boolean;
82
+ };
70
83
  showMoreBtn: {
71
84
  type: BooleanConstructor;
72
85
  default: boolean;
@@ -102,6 +115,10 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
102
115
  volumeValue: number;
103
116
  speed: number;
104
117
  } & import("vue/types/v3-component-options").ExtractComputedReturns<{}> & import("vue-demi").ComponentCustomProperties & Readonly<import("vue-demi").ExtractPropTypes<{
118
+ disabled: {
119
+ type: BooleanConstructor;
120
+ default: boolean;
121
+ };
105
122
  showMoreBtn: {
106
123
  type: BooleanConstructor;
107
124
  default: boolean;
@@ -127,6 +144,10 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
127
144
  default: number;
128
145
  };
129
146
  }>>, any, any, any, import("vue-demi").ComponentComputedOptions, import("vue-demi").ComponentMethodOptions> & import("vue/types/v3-component-options").ComponentOptionsBase<Readonly<import("vue-demi").ExtractPropTypes<{
147
+ disabled: {
148
+ type: BooleanConstructor;
149
+ default: boolean;
150
+ };
130
151
  showMoreBtn: {
131
152
  type: BooleanConstructor;
132
153
  default: boolean;
@@ -162,6 +183,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
162
183
  volumeValue: number;
163
184
  speed: number;
164
185
  }, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, {
186
+ disabled: boolean;
165
187
  showMoreBtn: boolean;
166
188
  showJumpToTime: boolean;
167
189
  audioSrc: string;
@@ -170,6 +192,10 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
170
192
  startTime: number;
171
193
  }> & {
172
194
  props: {
195
+ disabled: {
196
+ type: BooleanConstructor;
197
+ default: boolean;
198
+ };
173
199
  showMoreBtn: {
174
200
  type: BooleanConstructor;
175
201
  default: boolean;
@@ -1,5 +1,17 @@
1
- declare const _default: import("vue").DefineComponent<{}, any, {
1
+ declare const _default: import("vue").DefineComponent<{
2
+ disabled: {
3
+ type: BooleanConstructor;
4
+ default: boolean;
5
+ };
6
+ }, {}, {
2
7
  multipleArray: string[];
3
8
  speed: string;
4
- }, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
9
+ }, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{
10
+ disabled: {
11
+ type: BooleanConstructor;
12
+ default: boolean;
13
+ };
14
+ }>>, {
15
+ disabled: boolean;
16
+ }>;
5
17
  export default _default;
@@ -2,10 +2,11 @@
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
3
  const vueDemi = require("vue-demi");
4
4
  const vue2RuntimeHelpers = require("@94ai/vue2-runtime-helpers");
5
- const elementUi = require("element-ui");
5
+ const nfMessage = require("@94ai/nf-message");
6
6
  const __sfc_main = {};
7
7
  __sfc_main.props = {
8
- visible: [Boolean, String]
8
+ visible: [Boolean, String],
9
+ disabled: [Boolean]
9
10
  };
10
11
  __sfc_main.setup = (__props, __ctx) => {
11
12
  const emits = __ctx.emit;
@@ -26,7 +27,9 @@ __sfc_main.setup = (__props, __ctx) => {
26
27
  emits("update:visible", false);
27
28
  }
28
29
  function showPopper() {
29
- emits("update:visible", true);
30
+ if (!props.disabled) {
31
+ emits("update:visible", true);
32
+ }
30
33
  }
31
34
  vueDemi.onUnmounted(() => {
32
35
  emits("update:visible", false);
@@ -72,6 +75,12 @@ const volumeTool = __component__$2.exports;
72
75
  const _sfc_main$1 = {
73
76
  name: "more-btn",
74
77
  components: {},
78
+ props: {
79
+ disabled: {
80
+ type: Boolean,
81
+ default: false
82
+ }
83
+ },
75
84
  data() {
76
85
  return {
77
86
  multipleArray: ["1.0", "1.25", "1.5", "1.75", "2.0"],
@@ -97,7 +106,8 @@ var _sfc_render$1 = function render2() {
97
106
  }, [_c("el-popover", {
98
107
  attrs: {
99
108
  "placement": "right",
100
- "popper-class": "audio-popover"
109
+ "popper-class": "audio-popover",
110
+ "disabled": _vm.disabled
101
111
  }
102
112
  }, [_c("div", {
103
113
  staticClass: "audio-btn-list"
@@ -150,6 +160,10 @@ const _sfc_main = {
150
160
  moreBtn
151
161
  },
152
162
  props: {
163
+ disabled: {
164
+ type: Boolean,
165
+ default: false
166
+ },
153
167
  showMoreBtn: {
154
168
  type: Boolean,
155
169
  default: true
@@ -206,13 +220,15 @@ const _sfc_main = {
206
220
  },
207
221
  //暂停或播放
208
222
  handlePauseOrPlay() {
209
- if (this.audio.readyState >= 2) {
210
- this.audio.paused ? this.audio.play() : this.audio.pause();
211
- this.audio.playbackRate = this.speed;
212
- this.paused = !this.paused;
213
- } else {
214
- console.log("Audio is not ready yet.");
215
- elementUi.Message.warning("音频还未加载完成");
223
+ if (!this.disabled) {
224
+ if (this.audio.readyState >= 2) {
225
+ this.audio.paused ? this.audio.play() : this.audio.pause();
226
+ this.audio.playbackRate = this.speed;
227
+ this.paused = !this.paused;
228
+ } else {
229
+ console.log("Audio is not ready yet.");
230
+ nfMessage.Message.warning("音频还未加载完成");
231
+ }
216
232
  }
217
233
  },
218
234
  //视频在可以播放时触发
@@ -246,12 +262,14 @@ const _sfc_main = {
246
262
  },
247
263
  //点击进度条更新进度
248
264
  clickProgress(e) {
249
- if (this.duration === "00:00") {
250
- elementUi.Message.warning("音频还未加载完成");
251
- return false;
252
- }
253
- if (!this.audio.paused) {
254
- this.updateProgress(e.offsetX);
265
+ if (!this.disabled) {
266
+ if (this.duration === "00:00") {
267
+ nfMessage.Message.warning("音频还未加载完成");
268
+ return false;
269
+ }
270
+ if (!this.audio.paused) {
271
+ this.updateProgress(e.offsetX);
272
+ }
255
273
  }
256
274
  },
257
275
  //更新进度
@@ -263,54 +281,62 @@ const _sfc_main = {
263
281
  },
264
282
  //鼠标弹起
265
283
  handleMouseup() {
266
- if (this.duration === "00:00") {
267
- elementUi.Message.warning("音频还未加载完成");
268
- return false;
284
+ if (!this.disabled) {
285
+ if (this.duration === "00:00") {
286
+ nfMessage.Message.warning("音频还未加载完成");
287
+ return false;
288
+ }
289
+ const timer = setTimeout(() => {
290
+ this.audio.play();
291
+ this.paused = false;
292
+ clearTimeout(timer);
293
+ }, 200);
294
+ this.$once("hook:beforeDestroy", () => {
295
+ clearTimeout(timer);
296
+ });
269
297
  }
270
- const timer = setTimeout(() => {
271
- this.audio.play();
272
- this.paused = false;
273
- clearTimeout(timer);
274
- }, 200);
275
- this.$once("hook:beforeDestroy", () => {
276
- clearTimeout(timer);
277
- });
278
298
  },
279
299
  //调整进度
280
300
  handleMousedown() {
281
- this.audio.pause();
282
- this.paused = true;
283
- let progress = this.$refs.progress;
284
- let moveMin = progress.offsetParent.offsetLeft + progress.offsetLeft;
285
- let moveMax = progress.offsetParent.offsetLeft + progress.offsetLeft + progress.clientWidth;
286
- let circleWidth = this.$refs.circle.clientWidth / 2;
287
- let moveX = (e) => {
288
- if (e.pageX >= moveMax) {
289
- return;
290
- } else if (e.pageX <= moveMin) {
291
- return;
292
- }
293
- this.$refs.circle.style.left = e.pageX - moveMin - circleWidth + "px";
294
- this.updateProgress(e.pageX - moveMin);
295
- };
296
- document.addEventListener("mousemove", moveX);
297
- document.addEventListener("mouseup", () => {
298
- document.removeEventListener("mousemove", moveX);
299
- });
301
+ if (!this.disabled) {
302
+ this.audio.pause();
303
+ this.paused = true;
304
+ let progress = this.$refs.progress;
305
+ let moveMin = progress.offsetParent.offsetLeft + progress.offsetLeft;
306
+ let moveMax = progress.offsetParent.offsetLeft + progress.offsetLeft + progress.clientWidth;
307
+ let circleWidth = this.$refs.circle.clientWidth / 2;
308
+ let moveX = (e) => {
309
+ if (e.pageX >= moveMax) {
310
+ return;
311
+ } else if (e.pageX <= moveMin) {
312
+ return;
313
+ }
314
+ this.$refs.circle.style.left = e.pageX - moveMin - circleWidth + "px";
315
+ this.updateProgress(e.pageX - moveMin);
316
+ };
317
+ document.addEventListener("mousemove", moveX);
318
+ document.addEventListener("mouseup", () => {
319
+ document.removeEventListener("mousemove", moveX);
320
+ });
321
+ }
300
322
  },
301
323
  rangeVolume(val) {
302
324
  console.log(val);
303
325
  },
304
326
  /** 设置倍速播放 */
305
327
  changeSpeed(command) {
306
- const audioPlayer = this.$refs.audio;
307
- if (audioPlayer) {
308
- audioPlayer.playbackRate = command;
328
+ if (!this.disabled) {
329
+ const audioPlayer = this.$refs.audio;
330
+ if (audioPlayer) {
331
+ audioPlayer.playbackRate = command;
332
+ }
333
+ this.speed = command;
309
334
  }
310
- this.speed = command;
311
335
  },
312
336
  downRecord() {
313
- this.$emit("downloadCallback");
337
+ if (!this.disabled) {
338
+ this.$emit("downloadCallback");
339
+ }
314
340
  },
315
341
  calcMoveX() {
316
342
  if (!this.audio.paused) {
@@ -320,29 +346,31 @@ const _sfc_main = {
320
346
  }
321
347
  },
322
348
  jumpToTime() {
323
- this.audio.pause();
324
- const formatStartT = this.timeFormat(this.startTime);
325
- if (this.duration === "00:00") {
326
- elementUi.Message.warning("音频还未加载完成");
327
- return false;
328
- }
329
- if (formatStartT >= this.duration) {
330
- this.audio.currentTime = this.duration;
331
- this.currentDuration = this.timeFormat(this.audio.currentTime);
332
- this.calcMoveX();
333
- this.audio.play();
334
- console.error("开始时间不能大于总时长");
335
- return false;
336
- } else if (formatStartT >= "00:00" && formatStartT < this.duration) {
337
- this.audio.currentTime = this.startTime;
338
- this.currentDuration = this.timeFormat(this.audio.currentTime);
339
- this.calcMoveX();
340
- this.audio.play();
341
- } else {
342
- this.audio.currentTime = 0;
343
- this.currentDuration = this.timeFormat(this.audio.currentTime);
344
- this.calcMoveX();
345
- this.audio.play();
349
+ if (!this.disabled) {
350
+ this.audio.pause();
351
+ const formatStartT = this.timeFormat(this.startTime);
352
+ if (this.duration === "00:00") {
353
+ nfMessage.Message.warning("音频还未加载完成");
354
+ return false;
355
+ }
356
+ if (formatStartT >= this.duration) {
357
+ this.audio.currentTime = this.duration;
358
+ this.currentDuration = this.timeFormat(this.audio.currentTime);
359
+ this.calcMoveX();
360
+ this.audio.play();
361
+ console.error("开始时间不能大于总时长");
362
+ return false;
363
+ } else if (formatStartT >= "00:00" && formatStartT < this.duration) {
364
+ this.audio.currentTime = this.startTime;
365
+ this.currentDuration = this.timeFormat(this.audio.currentTime);
366
+ this.calcMoveX();
367
+ this.audio.play();
368
+ } else {
369
+ this.audio.currentTime = 0;
370
+ this.currentDuration = this.timeFormat(this.audio.currentTime);
371
+ this.calcMoveX();
372
+ this.audio.play();
373
+ }
346
374
  }
347
375
  }
348
376
  },
@@ -356,7 +384,10 @@ const _sfc_main = {
356
384
  var _sfc_render = function render3() {
357
385
  var _vm = this, _c = _vm._self._c;
358
386
  return _c("div", {
359
- staticClass: "nf-audio-strip"
387
+ staticClass: "nf-audio-strip",
388
+ class: {
389
+ disabled: _vm.disabled
390
+ }
360
391
  }, [_c("audio", {
361
392
  directives: [{
362
393
  name: "show",
@@ -431,7 +462,8 @@ var _sfc_render = function render3() {
431
462
  staticClass: "nf-volume-panel"
432
463
  }, [_c("volumeTool", {
433
464
  attrs: {
434
- "visible": _vm.volumeVisible
465
+ "visible": _vm.volumeVisible,
466
+ "disabled": _vm.disabled
435
467
  },
436
468
  on: {
437
469
  "update:visible": function($event) {
@@ -471,6 +503,9 @@ var _sfc_render = function render3() {
471
503
  })], 1)], 1), _vm.showMoreBtn ? _c("div", {
472
504
  staticClass: "option"
473
505
  }, [_c("moreBtn", {
506
+ attrs: {
507
+ "disabled": _vm.disabled
508
+ },
474
509
  on: {
475
510
  "down": function($event) {
476
511
  return _vm.downRecord();
@@ -1,9 +1,10 @@
1
1
  import { ref, watch, onUnmounted } from "vue-demi";
2
2
  import { normalizeComponent } from "@94ai/vue2-runtime-helpers";
3
- import { Message } from "element-ui";
3
+ import { Message } from "@94ai/nf-message";
4
4
  const __sfc_main = {};
5
5
  __sfc_main.props = {
6
- visible: [Boolean, String]
6
+ visible: [Boolean, String],
7
+ disabled: [Boolean]
7
8
  };
8
9
  __sfc_main.setup = (__props, __ctx) => {
9
10
  const emits = __ctx.emit;
@@ -24,7 +25,9 @@ __sfc_main.setup = (__props, __ctx) => {
24
25
  emits("update:visible", false);
25
26
  }
26
27
  function showPopper() {
27
- emits("update:visible", true);
28
+ if (!props.disabled) {
29
+ emits("update:visible", true);
30
+ }
28
31
  }
29
32
  onUnmounted(() => {
30
33
  emits("update:visible", false);
@@ -70,6 +73,12 @@ const volumeTool = __component__$2.exports;
70
73
  const _sfc_main$1 = {
71
74
  name: "more-btn",
72
75
  components: {},
76
+ props: {
77
+ disabled: {
78
+ type: Boolean,
79
+ default: false
80
+ }
81
+ },
73
82
  data() {
74
83
  return {
75
84
  multipleArray: ["1.0", "1.25", "1.5", "1.75", "2.0"],
@@ -95,7 +104,8 @@ var _sfc_render$1 = function render2() {
95
104
  }, [_c("el-popover", {
96
105
  attrs: {
97
106
  "placement": "right",
98
- "popper-class": "audio-popover"
107
+ "popper-class": "audio-popover",
108
+ "disabled": _vm.disabled
99
109
  }
100
110
  }, [_c("div", {
101
111
  staticClass: "audio-btn-list"
@@ -148,6 +158,10 @@ const _sfc_main = {
148
158
  moreBtn
149
159
  },
150
160
  props: {
161
+ disabled: {
162
+ type: Boolean,
163
+ default: false
164
+ },
151
165
  showMoreBtn: {
152
166
  type: Boolean,
153
167
  default: true
@@ -204,13 +218,15 @@ const _sfc_main = {
204
218
  },
205
219
  //暂停或播放
206
220
  handlePauseOrPlay() {
207
- if (this.audio.readyState >= 2) {
208
- this.audio.paused ? this.audio.play() : this.audio.pause();
209
- this.audio.playbackRate = this.speed;
210
- this.paused = !this.paused;
211
- } else {
212
- console.log("Audio is not ready yet.");
213
- Message.warning("音频还未加载完成");
221
+ if (!this.disabled) {
222
+ if (this.audio.readyState >= 2) {
223
+ this.audio.paused ? this.audio.play() : this.audio.pause();
224
+ this.audio.playbackRate = this.speed;
225
+ this.paused = !this.paused;
226
+ } else {
227
+ console.log("Audio is not ready yet.");
228
+ Message.warning("音频还未加载完成");
229
+ }
214
230
  }
215
231
  },
216
232
  //视频在可以播放时触发
@@ -244,12 +260,14 @@ const _sfc_main = {
244
260
  },
245
261
  //点击进度条更新进度
246
262
  clickProgress(e) {
247
- if (this.duration === "00:00") {
248
- Message.warning("音频还未加载完成");
249
- return false;
250
- }
251
- if (!this.audio.paused) {
252
- this.updateProgress(e.offsetX);
263
+ if (!this.disabled) {
264
+ if (this.duration === "00:00") {
265
+ Message.warning("音频还未加载完成");
266
+ return false;
267
+ }
268
+ if (!this.audio.paused) {
269
+ this.updateProgress(e.offsetX);
270
+ }
253
271
  }
254
272
  },
255
273
  //更新进度
@@ -261,54 +279,62 @@ const _sfc_main = {
261
279
  },
262
280
  //鼠标弹起
263
281
  handleMouseup() {
264
- if (this.duration === "00:00") {
265
- Message.warning("音频还未加载完成");
266
- return false;
282
+ if (!this.disabled) {
283
+ if (this.duration === "00:00") {
284
+ Message.warning("音频还未加载完成");
285
+ return false;
286
+ }
287
+ const timer = setTimeout(() => {
288
+ this.audio.play();
289
+ this.paused = false;
290
+ clearTimeout(timer);
291
+ }, 200);
292
+ this.$once("hook:beforeDestroy", () => {
293
+ clearTimeout(timer);
294
+ });
267
295
  }
268
- const timer = setTimeout(() => {
269
- this.audio.play();
270
- this.paused = false;
271
- clearTimeout(timer);
272
- }, 200);
273
- this.$once("hook:beforeDestroy", () => {
274
- clearTimeout(timer);
275
- });
276
296
  },
277
297
  //调整进度
278
298
  handleMousedown() {
279
- this.audio.pause();
280
- this.paused = true;
281
- let progress = this.$refs.progress;
282
- let moveMin = progress.offsetParent.offsetLeft + progress.offsetLeft;
283
- let moveMax = progress.offsetParent.offsetLeft + progress.offsetLeft + progress.clientWidth;
284
- let circleWidth = this.$refs.circle.clientWidth / 2;
285
- let moveX = (e) => {
286
- if (e.pageX >= moveMax) {
287
- return;
288
- } else if (e.pageX <= moveMin) {
289
- return;
290
- }
291
- this.$refs.circle.style.left = e.pageX - moveMin - circleWidth + "px";
292
- this.updateProgress(e.pageX - moveMin);
293
- };
294
- document.addEventListener("mousemove", moveX);
295
- document.addEventListener("mouseup", () => {
296
- document.removeEventListener("mousemove", moveX);
297
- });
299
+ if (!this.disabled) {
300
+ this.audio.pause();
301
+ this.paused = true;
302
+ let progress = this.$refs.progress;
303
+ let moveMin = progress.offsetParent.offsetLeft + progress.offsetLeft;
304
+ let moveMax = progress.offsetParent.offsetLeft + progress.offsetLeft + progress.clientWidth;
305
+ let circleWidth = this.$refs.circle.clientWidth / 2;
306
+ let moveX = (e) => {
307
+ if (e.pageX >= moveMax) {
308
+ return;
309
+ } else if (e.pageX <= moveMin) {
310
+ return;
311
+ }
312
+ this.$refs.circle.style.left = e.pageX - moveMin - circleWidth + "px";
313
+ this.updateProgress(e.pageX - moveMin);
314
+ };
315
+ document.addEventListener("mousemove", moveX);
316
+ document.addEventListener("mouseup", () => {
317
+ document.removeEventListener("mousemove", moveX);
318
+ });
319
+ }
298
320
  },
299
321
  rangeVolume(val) {
300
322
  console.log(val);
301
323
  },
302
324
  /** 设置倍速播放 */
303
325
  changeSpeed(command) {
304
- const audioPlayer = this.$refs.audio;
305
- if (audioPlayer) {
306
- audioPlayer.playbackRate = command;
326
+ if (!this.disabled) {
327
+ const audioPlayer = this.$refs.audio;
328
+ if (audioPlayer) {
329
+ audioPlayer.playbackRate = command;
330
+ }
331
+ this.speed = command;
307
332
  }
308
- this.speed = command;
309
333
  },
310
334
  downRecord() {
311
- this.$emit("downloadCallback");
335
+ if (!this.disabled) {
336
+ this.$emit("downloadCallback");
337
+ }
312
338
  },
313
339
  calcMoveX() {
314
340
  if (!this.audio.paused) {
@@ -318,29 +344,31 @@ const _sfc_main = {
318
344
  }
319
345
  },
320
346
  jumpToTime() {
321
- this.audio.pause();
322
- const formatStartT = this.timeFormat(this.startTime);
323
- if (this.duration === "00:00") {
324
- Message.warning("音频还未加载完成");
325
- return false;
326
- }
327
- if (formatStartT >= this.duration) {
328
- this.audio.currentTime = this.duration;
329
- this.currentDuration = this.timeFormat(this.audio.currentTime);
330
- this.calcMoveX();
331
- this.audio.play();
332
- console.error("开始时间不能大于总时长");
333
- return false;
334
- } else if (formatStartT >= "00:00" && formatStartT < this.duration) {
335
- this.audio.currentTime = this.startTime;
336
- this.currentDuration = this.timeFormat(this.audio.currentTime);
337
- this.calcMoveX();
338
- this.audio.play();
339
- } else {
340
- this.audio.currentTime = 0;
341
- this.currentDuration = this.timeFormat(this.audio.currentTime);
342
- this.calcMoveX();
343
- this.audio.play();
347
+ if (!this.disabled) {
348
+ this.audio.pause();
349
+ const formatStartT = this.timeFormat(this.startTime);
350
+ if (this.duration === "00:00") {
351
+ Message.warning("音频还未加载完成");
352
+ return false;
353
+ }
354
+ if (formatStartT >= this.duration) {
355
+ this.audio.currentTime = this.duration;
356
+ this.currentDuration = this.timeFormat(this.audio.currentTime);
357
+ this.calcMoveX();
358
+ this.audio.play();
359
+ console.error("开始时间不能大于总时长");
360
+ return false;
361
+ } else if (formatStartT >= "00:00" && formatStartT < this.duration) {
362
+ this.audio.currentTime = this.startTime;
363
+ this.currentDuration = this.timeFormat(this.audio.currentTime);
364
+ this.calcMoveX();
365
+ this.audio.play();
366
+ } else {
367
+ this.audio.currentTime = 0;
368
+ this.currentDuration = this.timeFormat(this.audio.currentTime);
369
+ this.calcMoveX();
370
+ this.audio.play();
371
+ }
344
372
  }
345
373
  }
346
374
  },
@@ -354,7 +382,10 @@ const _sfc_main = {
354
382
  var _sfc_render = function render3() {
355
383
  var _vm = this, _c = _vm._self._c;
356
384
  return _c("div", {
357
- staticClass: "nf-audio-strip"
385
+ staticClass: "nf-audio-strip",
386
+ class: {
387
+ disabled: _vm.disabled
388
+ }
358
389
  }, [_c("audio", {
359
390
  directives: [{
360
391
  name: "show",
@@ -429,7 +460,8 @@ var _sfc_render = function render3() {
429
460
  staticClass: "nf-volume-panel"
430
461
  }, [_c("volumeTool", {
431
462
  attrs: {
432
- "visible": _vm.volumeVisible
463
+ "visible": _vm.volumeVisible,
464
+ "disabled": _vm.disabled
433
465
  },
434
466
  on: {
435
467
  "update:visible": function($event) {
@@ -469,6 +501,9 @@ var _sfc_render = function render3() {
469
501
  })], 1)], 1), _vm.showMoreBtn ? _c("div", {
470
502
  staticClass: "option"
471
503
  }, [_c("moreBtn", {
504
+ attrs: {
505
+ "disabled": _vm.disabled
506
+ },
472
507
  on: {
473
508
  "down": function($event) {
474
509
  return _vm.downRecord();
@@ -1,4 +1,8 @@
1
1
  declare const _default: import("vue").DefineComponent<{
2
+ disabled: {
3
+ type: BooleanConstructor;
4
+ default: boolean;
5
+ };
2
6
  showMoreBtn: {
3
7
  type: BooleanConstructor;
4
8
  default: boolean;
@@ -34,6 +38,10 @@ declare const _default: import("vue").DefineComponent<{
34
38
  volumeValue: number;
35
39
  speed: number;
36
40
  }, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{
41
+ disabled: {
42
+ type: BooleanConstructor;
43
+ default: boolean;
44
+ };
37
45
  showMoreBtn: {
38
46
  type: BooleanConstructor;
39
47
  default: boolean;
@@ -59,6 +67,7 @@ declare const _default: import("vue").DefineComponent<{
59
67
  default: number;
60
68
  };
61
69
  }>>, {
70
+ disabled: boolean;
62
71
  showMoreBtn: boolean;
63
72
  showJumpToTime: boolean;
64
73
  audioSrc: string;
@@ -1,8 +1,10 @@
1
1
  declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineComponent<{}, {
2
2
  showPopper: typeof showPopper;
3
3
  $emit: (event: "update:visible", ...args: any[]) => void;
4
+ disabled?: boolean | undefined;
4
5
  visible?: string | boolean | undefined;
5
6
  $props: {
7
+ readonly disabled?: boolean | undefined;
6
8
  readonly visible?: string | boolean | undefined;
7
9
  };
8
10
  }, {}, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue-demi").ExtractPropTypes<{}>>, {}>, {
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div class="more-btn-box">
3
- <el-popover placement="right" popper-class="audio-popover">
3
+ <el-popover placement="right" popper-class="audio-popover" :disabled="disabled">
4
4
  <div class="audio-btn-list">
5
5
  <el-popover placement="right" popper-class="audio-popover">
6
6
  <div class="audio-btn-list">
@@ -21,6 +21,12 @@
21
21
  export default {
22
22
  name: 'more-btn',
23
23
  components: {},
24
+ props: {
25
+ disabled: {
26
+ type: Boolean,
27
+ default: false
28
+ },
29
+ },
24
30
  data() {
25
31
  return {
26
32
  multipleArray: ['1.0', '1.25', '1.5', '1.75', '2.0'],
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="nf-audio-strip">
2
+ <div class="nf-audio-strip" :class="{ disabled }">
3
3
  <audio @canplay="getDuration" controls crossOrigin="anonymous" @timeupdate="updateTime" @ended="handleAudioEnded" v-show="false" ref="audio"
4
4
  :src="audioSrc"/>
5
5
  <div class="nf-fast" v-if="showJumpToTime">
@@ -34,7 +34,7 @@
34
34
  </div>
35
35
  </div>
36
36
  <div class="nf-volume-panel">
37
- <volumeTool :visible.sync="volumeVisible">
37
+ <volumeTool :visible.sync="volumeVisible" :disabled="disabled">
38
38
  <template v-slot:reference>
39
39
  <i class="iconfont icon-yinliang_guanbi volume-mute" v-if="volume == 0" />
40
40
  <i class="iconfont icon-yinliang_kaiqi volume" v-else/>
@@ -52,7 +52,7 @@
52
52
  </volumeTool>
53
53
  </div>
54
54
  <div class="option" v-if="showMoreBtn">
55
- <moreBtn @down="downRecord()" @speed="changeSpeed" />
55
+ <moreBtn @down="downRecord()" @speed="changeSpeed" :disabled="disabled"/>
56
56
  </div>
57
57
  </div>
58
58
  </div>
@@ -61,12 +61,16 @@
61
61
  <script>
62
62
  import volumeTool from './volume-tool.vue'
63
63
  import moreBtn from './more-btn.vue'
64
- import { Message } from 'element-ui'
64
+ import { Message } from '@94ai/nf-message'
65
65
 
66
66
  export default {
67
67
  name: "nf-audio",
68
68
  components: { volumeTool, moreBtn },
69
69
  props: {
70
+ disabled: {
71
+ type: Boolean,
72
+ default: false
73
+ },
70
74
  showMoreBtn: {
71
75
  type: Boolean,
72
76
  default: true
@@ -123,14 +127,16 @@ export default {
123
127
  },
124
128
  //暂停或播放
125
129
  handlePauseOrPlay() {
126
- if (this.audio.readyState >= 2) {
127
- // 如果音频资源已加载元数据或更多,可以播放
128
- this.audio.paused ? this.audio.play() : this.audio.pause()
129
- this.audio.playbackRate = this.speed
130
- this.paused = !this.paused
131
- } else {
132
- console.log("Audio is not ready yet.");
133
- Message.warning("音频还未加载完成")
130
+ if (!this.disabled) {
131
+ if (this.audio.readyState >= 2) {
132
+ // 如果音频资源已加载元数据或更多,可以播放
133
+ this.audio.paused ? this.audio.play() : this.audio.pause()
134
+ this.audio.playbackRate = this.speed
135
+ this.paused = !this.paused
136
+ } else {
137
+ console.log("Audio is not ready yet.");
138
+ Message.warning("音频还未加载完成")
139
+ }
134
140
  }
135
141
  },
136
142
  //视频在可以播放时触发
@@ -171,13 +177,15 @@ export default {
171
177
  },
172
178
  //点击进度条更新进度
173
179
  clickProgress( e ) {
174
- if(this.duration === '00:00'){
175
- Message.warning("音频还未加载完成")
176
- return false
177
- }
178
- //如果不是正在移动 和 没有暂停播放就执行
179
- if (!this.audio.paused) {
180
- this.updateProgress(e.offsetX)
180
+ if (!this.disabled) {
181
+ if(this.duration === '00:00'){
182
+ Message.warning("音频还未加载完成")
183
+ return false
184
+ }
185
+ //如果不是正在移动 没有暂停播放就执行
186
+ if (!this.audio.paused) {
187
+ this.updateProgress(e.offsetX)
188
+ }
181
189
  }
182
190
  },
183
191
  //更新进度
@@ -192,61 +200,69 @@ export default {
192
200
  },
193
201
  //鼠标弹起
194
202
  handleMouseup() {
195
- if(this.duration === '00:00'){
196
- Message.warning("音频还未加载完成")
197
- return false
198
- }
199
- // 销毁的时候清除定时器
200
- const timer = setTimeout(() => {
201
- this.audio.play()
202
- this.paused = false
203
- clearTimeout(timer)
204
- }, 200)
203
+ if (!this.disabled) {
204
+ if(this.duration === '00:00'){
205
+ Message.warning("音频还未加载完成")
206
+ return false
207
+ }
208
+ // 销毁的时候清除定时器
209
+ const timer = setTimeout(() => {
210
+ this.audio.play()
211
+ this.paused = false
212
+ clearTimeout(timer)
213
+ }, 200)
205
214
 
206
- this.$once('hook:beforeDestroy', () => {
207
- clearTimeout(timer)
208
- })
215
+ this.$once('hook:beforeDestroy', () => {
216
+ clearTimeout(timer)
217
+ })
218
+ }
209
219
  },
210
220
  //调整进度
211
221
  handleMousedown() {
212
- this.audio.pause()
213
- this.paused = true
214
- let progress = this.$refs.progress
215
- //进度条 边距离页面左边的距离 移动最小值
216
- let moveMin = progress.offsetParent.offsetLeft + progress.offsetLeft
217
- //进度条 边距离页面左边的距离 移动最大值
218
- let moveMax = progress.offsetParent.offsetLeft + progress.offsetLeft + progress.clientWidth
219
- //小圆圈的宽度
220
- let circleWidth = ( this.$refs.circle.clientWidth / 2 )
221
- let moveX = ( e ) => {
222
- if (e.pageX >= moveMax) {
223
- return
224
- } else if (e.pageX <= moveMin) {
225
- return
222
+ if (!this.disabled) {
223
+ this.audio.pause()
224
+ this.paused = true
225
+ let progress = this.$refs.progress
226
+ //进度条 边距离页面左边的距离 移动最小值
227
+ let moveMin = progress.offsetParent.offsetLeft + progress.offsetLeft
228
+ //进度条 边距离页面左边的距离 移动最大值
229
+ let moveMax = progress.offsetParent.offsetLeft + progress.offsetLeft + progress.clientWidth
230
+ //小圆圈的宽度
231
+ let circleWidth = ( this.$refs.circle.clientWidth / 2 )
232
+ let moveX = ( e ) => {
233
+ if (e.pageX >= moveMax) {
234
+ return
235
+ } else if (e.pageX <= moveMin) {
236
+ return
237
+ }
238
+ this.$refs.circle.style.left = e.pageX - moveMin - circleWidth + 'px'
239
+ this.updateProgress(e.pageX - moveMin)
226
240
  }
227
- this.$refs.circle.style.left = e.pageX - moveMin - circleWidth + 'px'
228
- this.updateProgress(e.pageX - moveMin)
241
+ //获取当前鼠标的位置 X
242
+ document.addEventListener('mousemove', moveX)
243
+ //鼠标弹起来
244
+ document.addEventListener('mouseup', () => {
245
+ document.removeEventListener('mousemove', moveX)
246
+ })
229
247
  }
230
- //获取当前鼠标的位置 X
231
- document.addEventListener('mousemove', moveX)
232
- //鼠标弹起来
233
- document.addEventListener('mouseup', () => {
234
- document.removeEventListener('mousemove', moveX)
235
- })
236
248
  },
237
249
  rangeVolume(val){
238
250
  console.log(val);
239
251
  },
240
252
  /** 设置倍速播放 */
241
253
  changeSpeed(command) {
242
- const audioPlayer = this.$refs.audio
243
- if (audioPlayer) {
244
- audioPlayer.playbackRate = command
254
+ if (!this.disabled) {
255
+ const audioPlayer = this.$refs.audio
256
+ if (audioPlayer) {
257
+ audioPlayer.playbackRate = command
258
+ }
259
+ this.speed = command
245
260
  }
246
- this.speed = command
247
261
  },
248
262
  downRecord() {
249
- this.$emit('downloadCallback')
263
+ if (!this.disabled) {
264
+ this.$emit('downloadCallback')
265
+ }
250
266
  },
251
267
  calcMoveX() {
252
268
  if (!this.audio.paused) {
@@ -258,29 +274,31 @@ export default {
258
274
  }
259
275
  },
260
276
  jumpToTime(){
261
- this.audio.pause()
262
- const formatStartT = this.timeFormat(this.startTime)
263
- if(this.duration === '00:00'){
264
- Message.warning("音频还未加载完成")
265
- return false
266
- }
267
- if(formatStartT >= this.duration){
268
- this.audio.currentTime = this.duration
269
- this.currentDuration = this.timeFormat(this.audio.currentTime)
270
- this.calcMoveX()
271
- this.audio.play()
272
- console.error("开始时间不能大于总时长");
273
- return false
274
- }else if(formatStartT >= '00:00' && formatStartT < this.duration){
275
- this.audio.currentTime = this.startTime
276
- this.currentDuration = this.timeFormat(this.audio.currentTime)
277
- this.calcMoveX()
278
- this.audio.play()
279
- }else{
280
- this.audio.currentTime = 0
281
- this.currentDuration = this.timeFormat(this.audio.currentTime)
282
- this.calcMoveX()
283
- this.audio.play()
277
+ if (!this.disabled) {
278
+ this.audio.pause()
279
+ const formatStartT = this.timeFormat(this.startTime)
280
+ if(this.duration === '00:00'){
281
+ Message.warning("音频还未加载完成")
282
+ return false
283
+ }
284
+ if(formatStartT >= this.duration){
285
+ this.audio.currentTime = this.duration
286
+ this.currentDuration = this.timeFormat(this.audio.currentTime)
287
+ this.calcMoveX()
288
+ this.audio.play()
289
+ console.error("开始时间不能大于总时长");
290
+ return false
291
+ }else if(formatStartT >= '00:00' && formatStartT < this.duration){
292
+ this.audio.currentTime = this.startTime
293
+ this.currentDuration = this.timeFormat(this.audio.currentTime)
294
+ this.calcMoveX()
295
+ this.audio.play()
296
+ }else{
297
+ this.audio.currentTime = 0
298
+ this.currentDuration = this.timeFormat(this.audio.currentTime)
299
+ this.calcMoveX()
300
+ this.audio.play()
301
+ }
284
302
  }
285
303
  }
286
304
  },
@@ -16,7 +16,8 @@ import { watch, ref ,onUnmounted} from 'vue-demi'
16
16
 
17
17
  const emits = defineEmits(['update:visible'])
18
18
  const props = defineProps({
19
- visible: [Boolean, String]
19
+ visible: [Boolean, String],
20
+ disabled: [Boolean],
20
21
  })
21
22
  const reference = ref()
22
23
  const popperRef = ref()
@@ -38,7 +39,9 @@ function docClick(e){
38
39
  }
39
40
 
40
41
  function showPopper() {
41
- emits('update:visible', true)
42
+ if (!props.disabled) {
43
+ emits('update:visible', true)
44
+ }
42
45
  }
43
46
 
44
47
  onUnmounted(()=>{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-audio",
3
- "version": "3.3.51",
3
+ "version": "3.3.53",
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.51",
17
+ "@94ai/nf-theme-chalk": "^3.3.53",
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": "d5b493e6b5681b244f3f182b4ffb99f5dd24d63c"
33
+ "gitHead": "8e20e21ea67d158ed0a8246e18320f2432268704"
34
34
  }