微信小程序 audio 组件实例详解

编程学习 2021-07-04 20:00www.dzhlxh.cn编程入门
这篇文章主要介绍了微信小程序 audio 组件实例详解的相关资料,需要的朋友可以参考下

音频播放已经封装的很好!只需配合属性设置即可! (method和data配合使用)

主要属性:

wxml

<audio
 action="{{action}}"
 src='http://sc1.111ttt.com/2016/1/09/26/202261732256.mp3'
 poster= 'http://avatar.csdn.net/E/3/9/1_u014360817.jpg'
 controls="true"
 name="钢琴曲"
 author="不详"/>

<button type="primary" bindtap="audioPlay">播放</button>
<button type="primary" bindtap="audioPause">暂停</button>
<!--正常速度-->
<button type="primary" bindtap="audioPlaybackRateNormal">调为1倍速</button>
<!--慢放-->
<button type="primary" bindtap="audioPlaybackRateSlowDown">调为0.5倍速</button>

js

Page({
 data:{
 // text:"这是一个页面"
 action: {
  method: ''
 }
 },

 audioPlay:function() {
 this.setData({
  action: {
  method: 'play'
  }
 })
 },
 audioPause:function(){
 this.setData({
  action: {
  method: 'pause'
  }
 })
 },
 audioPlaybackRateNormal:function() {
 this.setData({
  action:{
  method: 'setPlaybackRate',
  data: 1
  }
 })
 },
audioPlaybackRateSlowDown:function() {
 this.setData({
 action: {
  method: 'setPlaybackRate',
  data: 0.5
 }
 })
}
})


相关文章:

                                                                                 
                                       
                                                                                          
                                                                                                 
                                                      
                                         
                                                    

Copyright © 2016-2025 www.dzhlxh.cn 金源码 版权所有 Power by

网站模板下载|网络推广|微博营销|seo优化|视频营销|网络营销|微信营销|网站建设|织梦模板|小程序模板