New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@liripeng/vue-audio-player

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@liripeng/vue-audio-player

适用于 PC 移动端的 Vue 音频播放器组件

  • 1.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.7K
increased by8.46%
Maintainers
1
Weekly downloads
 
Created
Source

Vue音频播放器组件

npm version Build Status


线上演示

image

特性

  • 经过童星汇 APP 线上业务检验的组件
  • 完善的文档和示例
  • 支持进度条拖拽(PC 端需引入一个库模拟 Touch 事件,库链接:https://github.com/hammerjs/touchemulator)
  • 原生 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'

components: {
  AudioPlayer
}

全局引入

import AudioPlayer from '@liripeng/vue-audio-player'
import '@liripeng/vue-audio-player/lib/vue-audio-player.css'

Vue.use(AudioPlayer)

使用

<template>
  <div>
    <AudioPlayer :audio-list="audioList"
                 :before-play="onBeforePlay" />
  </div>
</template>

<script>
import { AudioPlayer } from '@liripeng/vue-audio-player'
import '@liripeng/vue-audio-player/lib/vue-audio-player.css'

export default {
  components: {
    AudioPlayer
  },
  data() {
    return {
      audioList: [
        'http://txh-cdn.96qbhy.com/20180817175211dtC1vE3z.mp3',
        'http://txh-cdn.96qbhy.com/20181106105737sOcozMqw.mp3'
      ]
    }
  },
  methods: {
    // 播放前做的事
    onBeforePlay(next) {
        console.log('这里可以做一些事情...')
        next() // 开始播放
    }
  }
}
</script>

Prop

参数说明类型默认值
audio-list音频播放列表Array-
show-play-button是否显示播放按钮Booleantrue
show-prev-button是否显示上一首按钮Booleantrue
show-next-button是否显示下一首按钮Booleantrue
show-progress-bar是否显示进度条Booleantrue
isLoop是否列表循环播放Booleantrue
progressInterval进度更新间隔Number1000
before-play点击播放前的回调函数
调用 next() 后开始播放
(next)=>void-
before-prev点击上一首前的回调函数
调用 next() 后开始播放上一首
(next)=>void-
before-next点击下一首前的回调函数
调用 next() 后开始播放下一首
(next)=>void-

Event

事件说明回调
play点击播放后触发-
pause点击暂停后触发-
play-prev点击上一首后触发-
play-next点击下一首后触发-
playing播放中每 progressInterval 秒触发-
timeupdate当前的播放位置发送改变时触发event
loadedmetadata当媒介元素的持续时间以及其它媒介已加载数据时运行脚本触发event
ended音频播放结束后触发event

Data

变量说明默认值
currentPlayIndex当前播放的音频索引0
isPlaying音频是否正在播放false
duration音频持续时间-
currentTime音频当前播放时间-

使用 ref 调用, 更多请自行查看组件 data

Method

方法说明回调
play开始播放-
pause暂停播放-
playPrev播放上一首-
playNext播放下一首-

使用 ref 调用, 更多请自行查看组件 methods

更新日志

版本说明更新时间
v1.0.41. 修复 isLoop 无效
2. 简化类名
3. 支持原生 CSS
2019-10-16

许可证

MIT

最后

使用过程中发现任何问题都可以提 Issue,也非常欢迎提 PR

Keywords

FAQs

Package last updated on 21 Nov 2019

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc