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

ch-audio

v1.1.7

Published

this is a vue-audio component overwrite from native audio tags

Downloads

3

Readme

ch-audio

this is a vue-audio component overwrite from native audio tags

一个移动端的audio组件,自定义进度条,目前版本为0.1.0测试版本,初步解决了在ios以及andriod上的兼容问题。 npm引入:

npm install ch-audio

props

1、audioSrc

通过该属性传入音频地址。 本地音频请使用require()语法进行导入。

<ch-audio 
    :width="300" 
    audioSrc="require('./assets/111.mp3')"
    :playimg="require('./assets/play.png')"
    :stopimg="require('./assets/stop.png')"></ch-audio>
  </div>

注意!

ios获取音频,尽量使用服务器接口流模式,请在后端设置相应的响应头,koa.js参考如下:

router.get('/getsource/:filename',async ctx=>{
    console.log(ctx.params.filename);
    var mp3 = path.resolve('./view/source/' + ctx.params.filename);
    ctx.set({
        'Content-Type': 'audio/mpeg',
        'Content-Length': fs.statSync(mp3).size,
    })

    if (ctx.headers.range === 'bytes=0-1') { //ios音频预请求头,不处理则获取不到audio.duration
        ctx.set('Content-Range', `bytes 0-1/${fs.statSync(mp3).size}`)   // 重点在这
        ctx.body = '1'
    } else {
        ctx.set({
            'Accept-Ranges': 'bytes',
        })
        const src = fs.createReadStream(mp3)
        ctx.body = src
    }
});

2、playimg && stopimg

目前可以自定义播放以及暂停按钮的样式,本地图片请使用require()语法进行导入 例如:

<template>
  <div id="app">
    <ch-audio 
    audioSrc="require('./assets/111.mp3')"
    :playimg="require('./assets/play.png')"
    :stopimg="require('./assets/stop.png')"></ch-audio>
  </div>
</template>

3、width

可自定义宽度,通过width传入,number类型。

<template>
  <div id="app">
    <ch-audio 
    :width="300" 
    audioSrc="require('./assets/111.mp3')"
    :playimg="require('./assets/play.png')"
    :stopimg="require('./assets/stop.png')"></ch-audio>
  </div>
</template>

4、rem

目前支持rem模式,通过props:rem:'true'开启,开启后可使用rem; 例如:

<template>
  <div id="app">
    <ch-audio 
    :width="6" 
    :rem="true"  
    audioSrc="require('./assets/111.mp3')"
    :playimg="require('./assets/play.png')"
    :stopimg="require('./assets/stop.png')"></ch-audio>
  </div>
</template>