今天做微信小程序涉及到播放音频文件:
使用audio标签来绑定音频路径
[html] view plain copy
<audio id='audioid' src='{{vidioUrl}}' binderror="audioError" bindplay="audioPlay" bindeneded="playEnd" bindtimeupdate="timeUpdate"> </audio>
最上面的播放条是通过progress的percent来实现的,
[html] view plain copy
<progress percent="{{currtRate}}" stroke-width="2" activeColor="#ffd200" backgroundColor="#bcbcbc" />
通过currtRate来实现播放条的已播放长度界面:
[html] view plain copy
<view class="ub-ver info-container" style="height:5em;">
<!-- 音频播放 -->
<view class='ub fonts12 align-items-center' >
<view>{{currentTime}}</view>
<view class="umw-6"></view>
<view class='ub-f1'>
<progress percent="{{currtRate}}" stroke-width="2" activeColor="#ffd200" backgroundColor="#bcbcbc" />
<!-- {{vidioUrl}} -->
</view>
<view class="umw-6"></view>
<view>{{duration}}</view>
</view>
<audio id='audioid' src='{{vidioUrl}}' binderror="audioError" bindplay="audioPlay" bindeneded="playEnd" bindtimeupdate="timeUpdate"> </audio>