@aochuang/common 1.0.153 → 1.0.155
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.
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="bi-resizable" :class="['is-' + direction]">
|
|
3
3
|
<template v-if="direction === 'horizontal'">
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
<slot name="panel"></slot>
|
|
9
|
-
</div>
|
|
10
|
-
<div
|
|
11
|
-
class="bi-resizable__resizer"
|
|
12
|
-
:class="{ 'is-dragging': isDragging }"
|
|
13
|
-
@mousedown="startDrag"
|
|
14
|
-
@touchstart="startDrag"
|
|
15
|
-
>
|
|
16
|
-
<i
|
|
17
|
-
class="bi-resizable__resizer-icon"
|
|
18
|
-
@mousedown.stop="startDrag"
|
|
19
|
-
@touchstart.stop="startDrag"
|
|
20
|
-
title="拖拽调整宽度"
|
|
4
|
+
<template v-if="!hidePanel">
|
|
5
|
+
<div
|
|
6
|
+
class="bi-resizable__panel"
|
|
7
|
+
:style="panelStyle"
|
|
21
8
|
>
|
|
22
|
-
<
|
|
23
|
-
</
|
|
24
|
-
|
|
9
|
+
<slot name="panel"></slot>
|
|
10
|
+
</div>
|
|
11
|
+
<div
|
|
12
|
+
class="bi-resizable__resizer"
|
|
13
|
+
:class="{ 'is-dragging': isDragging }"
|
|
14
|
+
@mousedown="startDrag"
|
|
15
|
+
@touchstart="startDrag"
|
|
16
|
+
>
|
|
17
|
+
<i
|
|
18
|
+
class="bi-resizable__resizer-icon"
|
|
19
|
+
@mousedown.stop="startDrag"
|
|
20
|
+
@touchstart.stop="startDrag"
|
|
21
|
+
title="拖拽调整宽度"
|
|
22
|
+
>
|
|
23
|
+
<i></i><i></i><i></i><i></i>
|
|
24
|
+
</i>
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
25
27
|
<div class="bi-resizable__content">
|
|
26
28
|
<slot name="content"></slot>
|
|
27
29
|
</div>
|
|
@@ -30,7 +32,7 @@
|
|
|
30
32
|
<div class="bi-resizable__content">
|
|
31
33
|
<slot name="content"></slot>
|
|
32
34
|
</div>
|
|
33
|
-
<template v-if="$slots.panel">
|
|
35
|
+
<template v-if="$slots.panel && !hidePanel">
|
|
34
36
|
<div
|
|
35
37
|
class="bi-resizable__resizer"
|
|
36
38
|
:class="{ 'is-dragging': isDragging }"
|
|
@@ -77,6 +79,11 @@ export default {
|
|
|
77
79
|
maxSize: {
|
|
78
80
|
type: Number,
|
|
79
81
|
default: 400
|
|
82
|
+
},
|
|
83
|
+
// 隐藏panel区域(包括拖拽条),只显示content
|
|
84
|
+
hidePanel: {
|
|
85
|
+
type: Boolean,
|
|
86
|
+
default: false
|
|
80
87
|
}
|
|
81
88
|
},
|
|
82
89
|
data() {
|
|
@@ -50,14 +50,48 @@ export default class VoicePlayerAudio {
|
|
|
50
50
|
})
|
|
51
51
|
this.$audio.onerror = () => {
|
|
52
52
|
clearInterval(this._timer)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
const info = this._getErrorInfo()
|
|
54
|
+
// 元数据已经加载成功后才出现的解码错误(如mp3尾帧不完整,Windows Chrome的Symphonia解码器会报错),
|
|
55
|
+
// 不当成错误处理,直接按播放结束收尾
|
|
56
|
+
if (info.code === 3 && info.readyState > 0) {
|
|
57
|
+
this.options.onPlaying && this.options.onPlaying({
|
|
58
|
+
currPosition: Math.min(this.$audio.currentTime, this.$audio.duration),
|
|
59
|
+
totalPosition: this.$audio.duration
|
|
60
|
+
})
|
|
61
|
+
this._play = false
|
|
62
|
+
this.$audio.pause()
|
|
63
|
+
this.$audio.dispatchEvent(new Event('stop'))
|
|
64
|
+
return
|
|
65
|
+
}
|
|
66
|
+
this.options.onError && this.options.onError(info)
|
|
57
67
|
}
|
|
58
68
|
this.setPlaybackRate(this.options.playRate)
|
|
59
69
|
}
|
|
60
70
|
|
|
71
|
+
/**
|
|
72
|
+
* 获取audio元素的真实错误信息(MediaError code/message),方便定位是网络、解码还是格式不支持
|
|
73
|
+
*/
|
|
74
|
+
_getErrorInfo () {
|
|
75
|
+
const err = this.$audio.error
|
|
76
|
+
const codeMsgMap = {
|
|
77
|
+
1: 'MEDIA_ERR_ABORTED',
|
|
78
|
+
2: 'MEDIA_ERR_NETWORK',
|
|
79
|
+
3: 'MEDIA_ERR_DECODE',
|
|
80
|
+
4: 'MEDIA_ERR_SRC_NOT_SUPPORTED'
|
|
81
|
+
}
|
|
82
|
+
const info = {
|
|
83
|
+
url: this._url,
|
|
84
|
+
message: 'Invalid Url',
|
|
85
|
+
code: err ? err.code : null,
|
|
86
|
+
codeText: err ? codeMsgMap[err.code] : null,
|
|
87
|
+
detail: err ? err.message : null,
|
|
88
|
+
networkState: this.$audio.networkState,
|
|
89
|
+
readyState: this.$audio.readyState
|
|
90
|
+
}
|
|
91
|
+
console.warn('[VoicePlayerAudio] audio error', info)
|
|
92
|
+
return info
|
|
93
|
+
}
|
|
94
|
+
|
|
61
95
|
/**
|
|
62
96
|
* 设置播放倍率
|
|
63
97
|
*/
|
|
@@ -99,13 +133,13 @@ export default class VoicePlayerAudio {
|
|
|
99
133
|
}
|
|
100
134
|
const onError = () => {
|
|
101
135
|
cleanup()
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
message: 'Invalid Url'
|
|
105
|
-
})
|
|
136
|
+
const info = this._getErrorInfo()
|
|
137
|
+
this.options.onError && this.options.onError(info)
|
|
106
138
|
cb && cb({
|
|
107
139
|
status: 'error',
|
|
108
|
-
message:
|
|
140
|
+
message: info.message,
|
|
141
|
+
code: info.code,
|
|
142
|
+
detail: info.detail
|
|
109
143
|
})
|
|
110
144
|
}
|
|
111
145
|
const cleanup = () => {
|