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

aplayer-ts

v2.4.5

Published

TypeScript interface for aplayer

Downloads

124

Readme

Wow, such a lovely HTML5 music player

Fully ESM version of APlayer with TypeScript support. With Rollup and esbuild, index.min.js is 50% smaller than the original APlayer.min.js, from 58KB to less than 30KB.

Why this

See this blog post.

  1. TypeScript
  2. ESM (APlayer only exports APlayer.min.js, which is not friendly to code optimization)
  3. Tree-Shaking, see API difference
    # only import APlayer constructor
    demo_build/index.html                  1.95 kB │ gzip: 0.79 kB
    demo_build/assets/index-3p8iLQ3k.css  10.22 kB │ gzip: 2.19 kB
    demo_build/assets/index-DDEVMoCF.js   27.37 kB │ gzip: 8.66 kB
    # import everything
    demo_build/index.html                  1.95 kB │ gzip: 0.79 kB
    demo_build/assets/index-Bi0rxlmU.css  12.04 kB │ gzip: 2.47 kB
    demo_build/assets/index-CTXYaVj8.js   30.44 kB │ gzip: 9.23 kB

APlayer.min.js is still in dist folder, but by default this package exports src/js/index.js.

It also includes a patch which fixes APlayer#283.

Usage

Basic usage:

import APlayer from 'aplayer-ts'
import 'aplayer-ts/src/css/base.css'

const instance = APlayer()
    .init({ /* refer to the aplayer doc */ })

API difference

  1. fixed option is removed, use APlayerFixedModePlugin instead.
import APlayer, { APlayerFixedModePlugin } from 'aplayer-ts'
import 'aplayer-ts/src/css/base.css'
import 'aplayer-ts/src/css/fixed.css' // remember to import the css

const instance = APlayer()
    .use(APlayerFixedModePlugin)
    .init({ /* refer to the aplayer doc */ })
  1. list.add, list.remove and list.clear are by default removed, install their plugins if you want to use:
import APlayer, { addMusicPlugin, removeMusicPlugin, clearMusicPlugin } from 'aplayer-ts'
import 'aplayer-ts/src/css/base.css'

const instance = APlayer()
    .use(addMusicPlugin)
    .use(removeMusicPlugin)
    .init({ /* refer to the aplayer doc */ })

instance.list.add({ /* new audios here */ })
  1. HLS is by default removed, install APlayerHlsPlugin if you want to use:
import APlayer, { APlayerHlsPlugin } from 'aplayer-ts'
import 'aplayer-ts/src/css/base.css'

const instance = APlayer()
    .use(APlayerHlsPlugin)
    .init({ /* refer to the aplayer doc */ })

Development

Demo website:

pnpm dev         # start a dev server
pnpm build:demo  # build the demo website (to see output size)

Package build:

pnpm build       # ./build/index.{min}.js

APlayer relies on Webpack to import svg and art-template files. This package has already transformed these files into JavaScript code (see utils), so you don't need to worry about the compatibility of your bundler.