一款很好用的 Vue audio 插件 vue-audio-better

vue-audio-better

Easy to create custom audio player components for Vue.js.

Overview

demo.png

Installation

npm install  vue-audio-better --save

Setup

Bundler (Webpack, Rollup)

// in your entrypoint
import Vue from 'vue'
import VueAudio from 'vue-audio-better'

Vue.use(VueAudio)

Usage

Required Markup


  <vue-video
    :src="https://example.com/some_audio.mp3"
  ></vue-video>

Props

sources

Type: String[] - Required

An array of audio file urls

html5

Type: Boolean - Default: false

Whether to force HTML5 Audio

loop

Type: Boolean - Default: false

Whether to start the playback again
automatically after it is done playing

preload

Type: Boolean - Default: true

Whether to start downloading the audio
file when the component is mounted

autoplay

Type: Boolean - Default: false

Whether to start the playback
when the component is mounted

formats

Type: String[] - Default: []

Howler.js automatically detects your file format from the extension,
but you may also specify a format in situations where extraction won't work
(such as with a SoundCloud stream)

xhrWithCredentials

Type: Boolean - Default: false

Whether to enable the withCredentials flag on XHR requests
used to fetch audio files when using Web Audio API (see reference)

Development

Build

Bundle the js to the dist folder:

npm run build

Acknowledgements

howler.js
vue-howler

License

MIT

demo.png

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。