Socket
Socket
Sign inDemoInstall

@liripeng/vue-audio-player

Package Overview
Dependencies
32
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @liripeng/vue-audio-player

Simple and practical Vue audio player component for PC mobile terminal(简单实用的 PC 移动端的 Vue 音频播放器组件)


Version published
Weekly downloads
3.6K
increased by23.62%
Maintainers
1
Install size
35.3 MB
Created
Weekly downloads
 

Readme

Source

Vue Audio Player Component


中文文档 | English Document

Online Demo

Features

  • Vue2 and Vue3 are supported
  • Simple and practical
  • High versatility
  • Support for progress bar dragging
  • Supports PC and mobile terminals
  • Complete documentation and examples

Use

Step one:

npm i -S @liripeng/vue-audio-player

Step two:

// global import
import AudioPlayer from '@liripeng/vue-audio-player'

Vue.use(AudioPlayer)

or

// part import
import AudioPlayer from '@liripeng/vue-audio-player'

components: {
  AudioPlayer
}

Step three:

<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: 'audio1',
          url: 'https://www.0dutv.com/upload/dance/F25F74A0B8FF82503241801D0E2CA5CD.mp3'
        },
        {
          name: 'audio2',
          url: 'https://www.0dutv.com/upload/dance/20200316/C719452E3C7834080007662021EA968E.mp3'
        }
      ]
    }
  },

  methods: {
    // Something to do before playing
    handleBeforePlay(next) {
      // There are a few things you can do here...
      this.currentAudioName = this.audioList[this.$refs.audioPlayer.currentPlayIndex].name

      next() // Start playing
    }
  }
}
</script>

Prop

PropExplainTypeDefault
audio-listAudio playlistArray-
playback-ratesPlayrate setting listArray<Number>[0.5, 1, 1.5, 2]
show-play-buttonWhether to display the play buttonBooleantrue
show-prev-buttonWhether to display the previous buttonBooleantrue
show-next-buttonWhether to display the next buttonBooleantrue
show-volume-buttonWhether to display the volume buttonBooleantrue
show-progress-barWhether to display a progress barBooleantrue
show-playback-rateWhether to display the play rate buttonBooleantrue
show-play-loadingWhether to display loading on playbackBooleantrue
isLoopWhether the list plays in a loopBooleantrue
disabled-progress-dragDisable progress bar drag functionalityBooleanfalse
disabled-progress-clickDisable progress bar clickable functionalityBooleanfalse
progress-intervalProgress update intervalNumber1000
theme-colorTheme colorString#e35924
before-playThe callback function before the play starts
The play starts after next() is called
(next)=>void-
before-prevPlay the previous callback function
After calling next(), the previous song starts playing
(next)=>void-
before-nextPlay the callback function before the next song
After calling next(), the next song starts playing
(next)=>void-
The rest is consistent with native audio

Event

EventExplainCallback
playTriggers when the play starts-
pauseTrigger after play pause-
play-prevTriggers after playing the previous song-
play-nextTriggers after playing the next song-
play-errorTriggered after play error,The parameters are the same as those of the native 'play' methoddata
playingThe play fires every progressInterval second-
timeupdateTriggered when the current play position is sent to changeevent
loadedmetadataThe run script is triggered when the duration of the media element and other media have loaded dataevent
endedTrigger after audio playbackevent
progress-startTrigger before moving the progress barevent
progress-moveTriggered when moving the progress barevent
progress-endTriggered after moving the progress barevent
progress-clickClick the progress bar to triggerevent

Slot

NameExplain
play-prevPlay prev button,The replaceable button icon function remains unchanged
play-startPlay start button,The replaceable button icon function remains unchanged
play-pausePlay pause button,The replaceable button icon function remains unchanged
play-nextPlay next button,The replaceable button icon function remains unchanged

Data

VariableExplainDefault
currentPlayIndexThe audio index currently playing0
isPlayingWhether the audio is playingfalse
durationAudio duration''
currentTimeCurrent playback time of audio''
playbackRateCurrent playback rate of audio1

Call with ref,see the components for more data

Method

MethodExplainCallback
playStart-
pausePause-
playPrevPrevious-
playNextNext-

Call with ref,see the components for more methods

Update log

v1.5.3【2023/11/29】

  • Feature: showPlayLoading prop

v1.5.2【2023/07/12】

  • Fix: When I select double playback speed, it doesn't work when the next song is played.

v1.5.1【2023/03/29】

  • Improvement: Beautify UI

v1.5.0【2022/03/20】

  • Feature:Vue2 and Vue3 work fine
  • Feature:Don't need import CSS file

v1.4.0【2022/03/05】

  • Feature:Slot play-prevplay-startplay-pause and play-next
  • Feature:play-error event
  • Improvement:Appearance and layout

v1.3.0【2022/01/25】

  • Improvement:Reduced package volume
  • Modify:Style import changed to import '@liripeng/vue-audio-player/lib/style.css'

v1.2.11【2021/06/17】

  • Feature:disabled-progress-drag prop
  • Feature:disabled-progress-click prop
  • Feature:progress-start event
  • Feature:progress-move event
  • Feature:progress-end event
  • Feature:progress-click event

FAQ

Browser compatibility

  • Internet Explorer:not support
  • Firefox:53 and above
  • Chrome:51 and above

Reward the author with milk tea

License

MIT

Last

😘If you think it's helpful, click a 'Star',Any problem found in the process of use can be raised Issue, also very welcome to mention PR.

Keywords

FAQs

Last updated on 29 Nov 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc