npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-player-audio

v1.0.2

Published

播放音频文件,支持设置播放时间区间(Vue@2组件)

Downloads

145

Readme

vue-player-audio

播放音频文件,支持设置播放时间区间(Vue@2组件)

  1. npm:https://www.npmjs.com/package/vue-player-audio
  2. demo:https://realgeoffrey.github.io/vue-player-audio/demo/index.html

安装

  1. Node.js安装

    npm install vue-player-audio --save
  2. 浏览器引用

    <!-- 需要先引入vue:<script src="//unpkg.com/vue@2"></script> -->
    <script src="//unpkg.com/vue-player-audio"></script>

注册组件

  1. Node.js注册

    1. 全局注册

      import Vue from 'vue'
      import vuePlayerAudio from 'vue-player-audio'
      
      // 全局注册
      Vue.use(vuePlayerAudio, { component: 'PlayerAudio' }) // 组件名默认是:vue-player-audio
      // 或:Vue.component('PlayerAudio', vuePlayerAudio)
    2. 局部注册

      import vuePlayerAudio from 'vue-player-audio'
      
      export default {
        components: {
          // 局部注册
          PlayerAudio: vuePlayerAudio
        }
      }
  2. 浏览器注册

    1. 全局注册

      <!-- 需要先引入vue:<script src="//unpkg.com/vue@2"></script> -->
      <!-- 需要先引入vue-player-audio:<script src="//unpkg.com/vue-player-audio"></script> -->
      
      <script>
      // 全局注册
      Vue.use(vuePlayerAudio, { component: 'vue-player-audio' }) // 组件名默认是:vue-player-audio
      // 或:Vue.component('vue-player-audio', vuePlayerAudio)
      </script>
    2. 局部注册

      <!-- 需要先引入vue:<script src="//unpkg.com/vue@2"></script> -->
      <!-- 需要先引入vue-player-audio:<script src="//unpkg.com/vue-player-audio"></script> -->
      
      <script>
      new Vue({
        components: {
          // 局部注册
          'vue-player-audio': vuePlayerAudio
        }
      })
      </script>

用法

  1. 参数

    <PlayerAudio
      :audio-src="音频src(必填)"
      :start-second="开始秒数(0)"
      :end-second="结束秒数,0表示直到音频结束,起码播放1秒(0)"
    
      :autoplay="自动播放(false)"
      :loop="循环播放(false)"
      :loop-gap-millisecond="循环播放间隔时间-毫秒,起码间隔50毫秒(50)"
    
      :controls="展示控制面板(false)"
    
      :preload="预加载模式,none、metadata、auto('metadata')"
    />

    因为兼容性问题,end-secondstart-second最少间隔1秒,loop-gap-millisecond最少设置50毫秒。

  2. 插槽

    <PlayerAudio
      :audio-src="音频src(必填)"
      v-slot="audioData"
    >
      <br>
      是否在播放:{{ audioData.isPlaying }}
      <br>
      当前时间:{{ audioData.currentSecond }}
      <br>
      最大时间:{{ audioData.maxSecond }}
      <br>
    </PlayerAudio>

可使用audiosprite等音频组合工具把多个音频文件组合成一个,然后再使用本插件的音频播放时间区间,从而减少请求数。