![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@liripeng/vue-audio-player
Advanced tools
Simple and practical Vue audio player component for PC mobile terminal(简单实用的 PC 移动端的 Vue 音频播放器组件)
PC
移动端CSS
,无须引入 Less
、Scss
等预编译语言npm i -S @liripeng/vue-audio-player
// 全局引入
import AudioPlayer from '@liripeng/vue-audio-player'
import '@liripeng/vue-audio-player/lib/vue-audio-player.css'
Vue.use(AudioPlayer)
或者
// 局部引入
import AudioPlayer from '@liripeng/vue-audio-player'
import '@liripeng/vue-audio-player/lib/vue-audio-player.css'
components: {
AudioPlayer
}
<template>
<div>
{{ currentAudioName || audioList[0].name }}
<audio-player
ref="audioPlayer"
:audio-list="audioList.map(elm => elm.url)"
:before-play="handleBeforePlay"
theme-color="#ff2929"
/>
</div>
</template>
<script>
export default {
data() {
return {
currentAudioName: '',
audioList: [
{
name: '音频1',
url: 'https://www.0dutv.com/upload/dance/F25F74A0B8FF82503241801D0E2CA5CD.mp3'
},
{
name: '音频2',
url: 'https://www.0dutv.com/upload/dance/20200316/C719452E3C7834080007662021EA968E.mp3'
}
]
}
},
methods: {
// 播放前做的事
handleBeforePlay(next) {
// 这里可以做一些事情...
this.currentAudioName = this.audioList[this.$refs.audioPlayer.currentPlayIndex].name
next() // 开始播放
}
}
}
</script>
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
audio-list | 音频播放列表 | Array | - |
show-play-button | 是否显示播放按钮 | Boolean | true |
show-prev-button | 是否显示上一首按钮 | Boolean | true |
show-next-button | 是否显示下一首按钮 | Boolean | true |
show-volume-button | 是否显示音量按钮 | Boolean | true |
show-progress-bar | 是否显示进度条 | Boolean | true |
show-playback-rate | 是否显示播放速率按钮 | Boolean | true |
playback-rates | 播放速率设定列表 | Array<Number> | [0.5, 1, 1.5, 2] |
isLoop | 是否列表循环播放 | Boolean | true |
progress-interval | 进度更新间隔 | Number | 1000 |
theme-color | 主题色 | String | #e35924 |
before-play | 播放开始前的回调函数 调用 next() 后开始播放 | (next)=>void | - |
before-prev | 播放上一首前的回调函数 调用 next() 后开始播放上一首 | (next)=>void | - |
before-next | 播放下一首前的回调函数 调用 next() 后开始播放下一首 | (next)=>void | - |
其他的与原生 audio 一致 |
事件 | 说明 | 回调 |
---|---|---|
play | 播放开始后触发 | - |
pause | 播放暂停后触发 | - |
play-prev | 播放上一首后触发 | - |
play-next | 播放下一首后触发 | - |
playing | 播放中每 progressInterval 秒触发 | - |
timeupdate | 当前的播放位置发送改变时触发 | event |
loadedmetadata | 当媒介元素的持续时间以及其它媒介已加载数据时运行脚本触发 | event |
ended | 音频播放结束后触发 | event |
变量 | 说明 | 默认值 |
---|---|---|
currentPlayIndex | 当前播放的音频索引 | 0 |
isPlaying | 音频是否正在播放 | false |
duration | 音频持续时间 | '' |
currentTime | 音频当前播放时间 | '' |
playbackRate | 音频当前播放速率 | 1 |
使用 ref
调用, 更多请自行查看组件 data
方法 | 说明 | 回调 |
---|---|---|
play | 开始播放 | - |
pause | 暂停播放 | - |
playPrev | 播放上一首 | - |
playNext | 播放下一首 | - |
使用 ref
调用, 更多请自行查看组件 methods
hover
效果theme-color
PC
端无须引入 hammer-touchemulator
即可拖拽show-playback-rate
属性show-volume-button
属性is-auto-playNext
属性is-auto-playNext
为 false
则不会自动播放下一首svg
动画,可用 CSS
覆盖颜色play
事件触发调前MIT
使用过程中发现任何问题都可以提 Issue
,也非常欢迎提 PR
FAQs
Simple and practical Vue audio player component for PC mobile terminal(简单实用的 PC 移动端的 Vue 音频播放器组件)
The npm package @liripeng/vue-audio-player receives a total of 2,843 weekly downloads. As such, @liripeng/vue-audio-player popularity was classified as popular.
We found that @liripeng/vue-audio-player demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.