1.1.0 • Published 3 years ago

zy_audio v1.1.0

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

A Vue.js 2.0 Component for Web.

zyAudio will stay with Vue 2.x

Install

npm:
npm i zy_audio -S

yarn:
yarn add zy_audio

Quick Start

全局引入

import zyAudio from 'zy_audio' import 'zy_audio/lib/zyAudio.css'

Vue.use(zyAudio)

局部使用

import zyAudio from 'zy_audio' import 'zy_audio/lib/zyAudio.css'

components: { AudioPlayer }

属性

参数说明类型默认值
src/v-model资源地址String-
is-loop是否循环播放当前章节Booleantrue
forward-back是否显示快退、快进按钮Booleantrue
max-index最大索引值number0
current-index当前播放索引值number0
theme-color主题色String#dfc190
show-play-button是否显示播放按钮Booleantrue
show-prev-button是否显示上一章按钮Booleantrue
show-next-button是否显示下一章按钮Booleantrue
show-progress-bar是否显示进度条Booleantrue
disabled-drag进度条是否可拖拽Booleantrue
before-play播放开始前的钩子调用 next() 后开始播放(next)=>void-
before-prev播放上一章节前的钩子调用 next() 后开始播放上一章(next)=>void-
before-next播放下一章前的钩子调用 next() 后开始播放下一首章(next)=>void-
on-time-update播放位置改变时触发function(object){currentTime}

事件

事件说明回调参数
play播放开始后触发function{type: 'play', currentTime}
pause播放暂停后触发function{type: 'play', currentTime}
loaded-metadata元数据加载完成function(event)-
on-end当前章节播放完回调function(event)-
can-play浏览器已经可以播放媒体(同audio canplay)function(event)-
progress-move拖动进度条时触发function(event)Number
setPlayRate设置播放速度-Number
setLoop设置当前章节是否循环播放-Boolean