1.1.3 • Published 4 years ago

taro-audio v1.1.3

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

代码演示

引入

    import AudioPlayer from 'taro-audio';

基础用法

通过src属性设置音频资源的地址

    <AudioPlayer src={'你的路径'}/>

lvruHP.png

显示音频名称

通过title属性显示音频名称

    <AudioPlayer src={'你的路径'} title='泡沫'/>

lvr39g.png

显示作者

通过author属性显示作者

<AudioPlayer src={'你的路径'} title='泡沫' author='邓紫棋'/>

lvr83Q.png

自动播放

通过autoplay设置

<AudioPlayer src={'你的路径'} title='泡沫' author='邓紫棋' autoplay />

lvrQN8.png

进度条是否可拖拽

通过draggable设置

 <AudioPlayer src={'你的路径'} title='泡沫' author='邓紫棋' autoplay={true} draggable={false}/>

lvrnBt.png

设置海报

通过poster设置

<AudioPlayer src={'你的路径'} title='泡沫' author='邓紫棋' autoplay={false} draggable poster={'你的路径'}/>

lxn3vj.png

Props

参数说明类型默认值是否必须
src音频资源的地址string
draggable是否可以拖动进度条booleantrue
title音频名称string
author音频作者string
autoplay是否自动播放booleanfalse
poster音频海报string
onPlay当开始/继续播放时触发play事件eventHandle
onPause当暂停播放时触发 pause 事件eventHandle
onEnded当播放到末尾时触发 ended 事件eventHandle
onTimeUpdate当播放进度改变时触发 timeupdate 事件,detail = {currentTime, duration}eventHandle
onError当发生错误时触发 error 事件,detail = {errMsg:MediaError.code}eventHandle