@aochuang/common 1.0.132 → 1.0.133

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.
@@ -90,18 +90,34 @@ export default class VoicePlayerAudio {
90
90
  if (!url) {
91
91
  this.stop()
92
92
  }
93
- this.$audio.src = url
94
- if (play) {
95
- this.start()
96
- }
97
- const eventCb = () => {
93
+ const onLoaded = () => {
94
+ cleanup()
98
95
  cb && cb({
99
96
  duration: this.$audio.duration,
100
97
  status: 'success'
101
98
  })
102
- this.$audio.removeEventListener('loadedmetadata', eventCb)
103
99
  }
104
- this.$audio.addEventListener('loadedmetadata', eventCb)
100
+ const onError = () => {
101
+ cleanup()
102
+ this.options.onError && this.options.onError({
103
+ url: this._url,
104
+ message: 'Invalid Url'
105
+ })
106
+ cb && cb({
107
+ status: 'error',
108
+ message: 'Invalid Url'
109
+ })
110
+ }
111
+ const cleanup = () => {
112
+ this.$audio.removeEventListener('loadedmetadata', onLoaded)
113
+ this.$audio.removeEventListener('error', onError)
114
+ }
115
+ this.$audio.addEventListener('loadedmetadata', onLoaded)
116
+ this.$audio.addEventListener('error', onError)
117
+ this.$audio.src = url
118
+ if (play) {
119
+ this.start()
120
+ }
105
121
  }
106
122
 
107
123
  /**
@@ -81,11 +81,25 @@ export default {
81
81
  }
82
82
  },
83
83
  created () {
84
+ const resolvePendingStart = () => {
85
+ if (this._pendingStartResolve) {
86
+ this._pendingStartResolve()
87
+ this._pendingStartResolve = null
88
+ }
89
+ }
90
+ const releasePlayEndPromise = () => {
91
+ if (this.playEndPromise && this.playEndPromise.resolve) {
92
+ this.playEndPromise.resolve()
93
+ }
94
+ }
84
95
  const newFactory = (Factory, options) => {
85
96
  return new Factory(Object.assign({
86
97
  playRate: this.playRate,
87
98
  onError: (e) => {
88
99
  this.starting = false
100
+ this.playStatus = 'stop'
101
+ resolvePendingStart()
102
+ releasePlayEndPromise()
89
103
  this.$set(this.errorMsgMap, this.playId, e.message || '未知错误')
90
104
  this.$emit('error', Object.assign({
91
105
  playId: this.playId
@@ -164,22 +178,32 @@ export default {
164
178
  start (id, val, total, cb) {
165
179
  return new Promise((resolve) => {
166
180
  this.stop()
181
+ this._pendingStartResolve = resolve
167
182
  const playEndPromise = this.playEndPromise || Promise.resolve()
168
183
  playEndPromise.finally(() => {
169
184
  this.playEndPromise = createPromise()
170
185
  val = formatOssPath(val)
171
186
  this.starting = true
172
187
  this.playUrl = val
188
+ this.playId = id
173
189
  this.$delete(this.errorMsgMap, id)
174
190
  this.$nextTick(() => {
175
191
  this.player.setUrl(val, (ctx) => {
176
192
  cb && cb(ctx)
193
+ if (!ctx || ctx.status !== 'success') {
194
+ this.starting = false
195
+ this.playStatus = 'stop'
196
+ resolvePendingStart()
197
+ releasePlayEndPromise()
198
+ resolve()
199
+ return
200
+ }
177
201
  this._resetPosition(total)
178
- this.playId = id
179
202
  this.playStatus = 'play'
180
203
  Promise.all([
181
204
  this.player.start()
182
205
  ]).finally(() => {
206
+ resolvePendingStart()
183
207
  resolve()
184
208
  })
185
209
  })
@@ -204,6 +228,10 @@ export default {
204
228
  this.starting = false
205
229
  this.playId = null
206
230
  this.playStatus = 'stop'
231
+ if (this._pendingStartResolve) {
232
+ this._pendingStartResolve()
233
+ this._pendingStartResolve = null
234
+ }
207
235
  this.player.stop()
208
236
  },
209
237
  isPlaying (id) {
@@ -302,14 +302,10 @@ export default {
302
302
  this.AcVoice.$on('end', this.handleVoiceEnd)
303
303
  this.AcVoice.$on('error', this.handleVoiceError)
304
304
  },
305
- beforeDestroy () {
306
- this.AcVoice.remove(this.id)
307
- this.AcVoice.$off('playing', this.handleVoicePlaying)
308
- this.AcVoice.$off('end', this.handleVoiceEnd)
309
- this.AcVoice.$off('error', this.handleVoiceError)
310
- },
311
305
  methods: {
312
306
  handleVoiceError (e) {
307
+ this.loading = false
308
+ this.progressing = false
313
309
  if (e.type === 'aac' && e.playId === this.id) {
314
310
  if (e.message && e.message === 'Maximum call stack size exceeded') {
315
311
  if (this.allowDownload) {
@@ -321,9 +317,11 @@ export default {
321
317
  }
322
318
  },
323
319
  handleVoiceEnd () {
320
+ this.loading = false
324
321
  this.progressing = false
325
322
  },
326
323
  handleVoicePlaying (evt) {
324
+ this.loading = false
327
325
  this.isSuperChangeProgress = this.AcVoice.isSuperChangeProgress(this.innerUrl)
328
326
  if (!this.isNeedConvertWav) {
329
327
  return
@@ -497,6 +495,10 @@ export default {
497
495
  }
498
496
  },
499
497
  beforeDestroy () {
498
+ this.AcVoice.remove(this.id)
499
+ this.AcVoice.$off('playing', this.handleVoicePlaying)
500
+ this.AcVoice.$off('end', this.handleVoiceEnd)
501
+ this.AcVoice.$off('error', this.handleVoiceError)
500
502
  clearTimeout(this._controlChangeTimer)
501
503
  }
502
504
  }
@@ -54,6 +54,12 @@
54
54
  <div class="content unicode" style="display: block;">
55
55
  <ul class="icon_lists dib-box">
56
56
 
57
+ <li class="dib">
58
+ <span class="icon iconfont">&#xe89b;</span>
59
+ <div class="name">upload-2-fill</div>
60
+ <div class="code-name">&amp;#xe89b;</div>
61
+ </li>
62
+
57
63
  <li class="dib">
58
64
  <span class="icon iconfont">&#xe6f9;</span>
59
65
  <div class="name">bookmark-3-line</div>
@@ -2406,9 +2412,9 @@
2406
2412
  <pre><code class="language-css"
2407
2413
  >@font-face {
2408
2414
  font-family: 'iconfont';
2409
- src: url('iconfont.woff2?t=1785737622729') format('woff2'),
2410
- url('iconfont.woff?t=1785737622729') format('woff'),
2411
- url('iconfont.ttf?t=1785737622729') format('truetype');
2415
+ src: url('iconfont.woff2?t=1785898568941') format('woff2'),
2416
+ url('iconfont.woff?t=1785898568941') format('woff'),
2417
+ url('iconfont.ttf?t=1785898568941') format('truetype');
2412
2418
  }
2413
2419
  </code></pre>
2414
2420
  <h3 id="-iconfont-">第二步:定义使用 iconfont 的样式</h3>
@@ -2434,6 +2440,15 @@
2434
2440
  <div class="content font-class">
2435
2441
  <ul class="icon_lists dib-box">
2436
2442
 
2443
+ <li class="dib">
2444
+ <span class="icon iconfont icon-upload-2-fill"></span>
2445
+ <div class="name">
2446
+ upload-2-fill
2447
+ </div>
2448
+ <div class="code-name">.icon-upload-2-fill
2449
+ </div>
2450
+ </li>
2451
+
2437
2452
  <li class="dib">
2438
2453
  <span class="icon iconfont icon-bookmark-3-line"></span>
2439
2454
  <div class="name">
@@ -5962,6 +5977,14 @@
5962
5977
  <div class="content symbol">
5963
5978
  <ul class="icon_lists dib-box">
5964
5979
 
5980
+ <li class="dib">
5981
+ <svg class="icon svg-icon" aria-hidden="true">
5982
+ <use xlink:href="#icon-upload-2-fill"></use>
5983
+ </svg>
5984
+ <div class="name">upload-2-fill</div>
5985
+ <div class="code-name">#icon-upload-2-fill</div>
5986
+ </li>
5987
+
5965
5988
  <li class="dib">
5966
5989
  <svg class="icon svg-icon" aria-hidden="true">
5967
5990
  <use xlink:href="#icon-bookmark-3-line"></use>
@@ -13,7 +13,7 @@ export default {
13
13
  size: {
14
14
  type: Number
15
15
  },
16
- color: {
16
+ color: {
17
17
  type: String
18
18
  }
19
19
  },
@@ -1,8 +1,8 @@
1
1
  @font-face {
2
2
  font-family: "iconfont"; /* Project id 4387417 */
3
- src: url('iconfont.woff2?t=1785737622729') format('woff2'),
4
- url('iconfont.woff?t=1785737622729') format('woff'),
5
- url('iconfont.ttf?t=1785737622729') format('truetype');
3
+ src: url('iconfont.woff2?t=1785898568941') format('woff2'),
4
+ url('iconfont.woff?t=1785898568941') format('woff'),
5
+ url('iconfont.ttf?t=1785898568941') format('truetype');
6
6
  }
7
7
 
8
8
  .iconfont {
@@ -13,6 +13,10 @@
13
13
  -moz-osx-font-smoothing: grayscale;
14
14
  }
15
15
 
16
+ .icon-upload-2-fill:before {
17
+ content: "\e89b";
18
+ }
19
+
16
20
  .icon-bookmark-3-line:before {
17
21
  content: "\e6f9";
18
22
  }