@explorer-1/vue 1.1.13 → 1.1.14
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/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -215,6 +215,8 @@ export default defineComponent({
|
|
|
215
215
|
this.audio.removeEventListener('loadeddata', this._handleLoaded)
|
|
216
216
|
this.audio.removeEventListener('pause', this._handlePlayPause)
|
|
217
217
|
this.audio.removeEventListener('play', this._handlePlayPause)
|
|
218
|
+
this.audio.removeEventListener('durationchange', this._handleDurationChange)
|
|
219
|
+
this.audio.removeEventListener('loadedmetadata', this._handleDurationChange)
|
|
218
220
|
}
|
|
219
221
|
},
|
|
220
222
|
methods: {
|
|
@@ -259,6 +261,9 @@ export default defineComponent({
|
|
|
259
261
|
if (this.playing && !this.paused) {
|
|
260
262
|
return
|
|
261
263
|
} else if (this.audio) {
|
|
264
|
+
if (this.totalDuration === 0 && !isNaN(this.audio.duration)) {
|
|
265
|
+
this.totalDuration = this.audio.duration
|
|
266
|
+
}
|
|
262
267
|
this.paused = false
|
|
263
268
|
this.audio.play()
|
|
264
269
|
this.playing = true
|
|
@@ -295,7 +300,7 @@ export default defineComponent({
|
|
|
295
300
|
if (this.autoPlay) this.play()
|
|
296
301
|
|
|
297
302
|
this.loaded = true
|
|
298
|
-
this.totalDuration = this.audio.duration
|
|
303
|
+
this.totalDuration = isNaN(this.audio.duration) ? 0 : this.audio.duration
|
|
299
304
|
} else {
|
|
300
305
|
throw new Error('Failed to load audio file')
|
|
301
306
|
}
|
|
@@ -325,6 +330,11 @@ export default defineComponent({
|
|
|
325
330
|
_handleEnded() {
|
|
326
331
|
this.paused = this.playing = false
|
|
327
332
|
},
|
|
333
|
+
_handleDurationChange() {
|
|
334
|
+
if (this.audio) {
|
|
335
|
+
this.totalDuration = isNaN(this.audio.duration) ? 0 : this.audio.duration
|
|
336
|
+
}
|
|
337
|
+
},
|
|
328
338
|
init() {
|
|
329
339
|
if (this.audio) {
|
|
330
340
|
this.audio.addEventListener('timeupdate', this._handlePlayingUI)
|
|
@@ -332,6 +342,13 @@ export default defineComponent({
|
|
|
332
342
|
this.audio.addEventListener('pause', this._handlePlayPause)
|
|
333
343
|
this.audio.addEventListener('play', this._handlePlayPause)
|
|
334
344
|
this.audio.addEventListener('ended', this._handleEnded)
|
|
345
|
+
this.audio.addEventListener('loadedmetadata', this._handleDurationChange)
|
|
346
|
+
this.audio.addEventListener('durationchange', this._handleDurationChange)
|
|
347
|
+
|
|
348
|
+
// Fallback: metadata already available before calling init() (e.g. cached audio)
|
|
349
|
+
if (this.totalDuration === 0 && !isNaN(this.audio.duration)) {
|
|
350
|
+
this.totalDuration = this.audio.duration
|
|
351
|
+
}
|
|
335
352
|
}
|
|
336
353
|
// TODO: VUE3: pass uuID to pauseOthers() method
|
|
337
354
|
// eventBus.on('play', () => this.pauseOthers())
|