taro-audio

1.1.3 • Public • Published

代码演示

引入

    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 是否可以拖动进度条 boolean true
title 音频名称 string
author 音频作者 string
autoplay 是否自动播放 boolean false
poster 音频海报 string
onPlay 当开始/继续播放时触发play事件 eventHandle
onPause 当暂停播放时触发 pause 事件 eventHandle
onEnded 当播放到末尾时触发 ended 事件 eventHandle
onTimeUpdate 当播放进度改变时触发 timeupdate 事件,detail = {currentTime, duration} eventHandle
onError 当发生错误时触发 error 事件,detail = {errMsg:MediaError.code} eventHandle

Readme

Keywords

Package Sidebar

Install

npm i taro-audio

Weekly Downloads

7

Version

1.1.3

License

ISC

Unpacked Size

26.1 kB

Total Files

32

Last publish

Collaborators

  • justsso