提交 f099d534 authored 作者: quanlili's avatar quanlili

判断音频文件是否获取到时长

上级 2a719711
......@@ -19,12 +19,14 @@
<!-- 播放进度条 -->
<el-slider
v-show="!controlList.noProcess"
:disabled="disabledFleg"
v-model="sliderTime"
:format-tooltip="formatProcessToolTip"
@change="changeCurrentTime"
class="slider" ></el-slider>
<!-- 播放时间进度 -->
<span class="audio-time">{{ audio.currentTime | formatSecond}} / {{ audio.maxTime | formatSecond }}</span>
<span v-if="showTime" class="audio-time">{{ audio.currentTime | formatSecond}} / {{ audio.maxTime | formatSecond }}</span>
<span v-else>{{ audio.currentTime | formatSecond}}</span>
<!-- 控制播放静音 -->
<a
v-show="!controlList.noMuted"
......@@ -53,6 +55,8 @@
name: 'VueAudio',
data() {
return {
disabledFleg:false,
showTime:true,
url: this.audioUrl || 'http://front-end.bjcnc.scs.sohucs.com/track-report-sit/falling-star.mp3',
audio: {
currentTime: 0,
......@@ -90,7 +94,12 @@
// 进度条toolTip
formatProcessToolTip(index = 0) {
index = parseInt(this.audio.maxTime / 100 * index)
return '进度条: ' + realFormatSecond(index)
if(this.showTime){
return '进度条: ' + realFormatSecond(index)
}else{
return '禁止拖拽'
}
//return '进度条: ' + realFormatSecond(index)
},
// 播放跳转
changeCurrentTime(index) {
......@@ -152,7 +161,11 @@
console.log('loadedmetadata')
console.log(res)
this.audio.waiting = false
this.audio.maxTime = parseInt(res.target.duration)
this.audio.maxTime = parseInt(res.target.duration);
if(res.target.duration===Infinity){
this.showTime=false;
this.disabledFleg=true
}
}
},
filters: {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论