beautiful player

TypeScript

Custom-made audio player delivered as a Web Component with first-class wrappers for React, Vue 3 and Angular.

Beautiful Player

Beautiful Player screenshot

Beautiful Player demo


npm Custom-made audio player delivered as a Web Component with first-class wrappers for React, Vue 3 and Angular.

Roadmap · upcoming modules
• Video player 📹 • Voice recorder 🎙 • Stories / playlists 📚


1 · Installation

npm i beautiful-player

CDN (no build-step):

<script type="module" src="https://unpkg.com/beautiful-player/dist/beautiful-player.esm.js"></script>

2 · Web Component usage

Full example

<beautiful-audio
  src="song.mp3"
  speeds="0.75,1,1.25,1.5"
  primary-color="#ff006e"
  icon-play="▶" icon-pause="⏸" icon-download="⬇"
  hide-buttons="volume"
  autoplay
></beautiful-audio>

Attributes (Web Component)

AttributeTypeDefaultDescription
srcstringAudio URL
typestringMIME hint, e.g. audio/ogg
speedsstring1,1.5,2Comma-separated playback rates
autoplaybooleanfalseStart playback on load
primary-colorstring#222375Brand color (background)
icon-sizestring | number48Base icon/button size (w = h)
icon-colorstring--primaryIcon/text color
width / heightstring | numberExplicit player box size
hide-buttonsstringCSV speed,volume,download
hide-speed / hide-volume / hide-downloadbooleanIndividual flags
icon-play / icon-pause / icon-downloadstringbuilt-in SVGsOverride any icon (SVG/text)
tooltipsboolean | JSONtruefalse to disable or JSON object to override (HTML allowed)
crossorigin"anonymous" | "use-credentials"Enable CORS for wave visualizer

Events

All native <audio> events bubble. Extra download event:

document.querySelector('beautiful-audio')
  .addEventListener('download', e => {
    console.log(e.detail.url)   // audio file
    // e.preventDefault()       // cancel native download
  })

Custom tooltip example

<beautiful-audio
  src="song.mp3"
  icon-size="40"
  tooltips='{"play":"<strong>Play</strong>","download":"<em>Save file</em>"}'>
</beautiful-audio>

3 · Official wrappers

FrameworkImportQuick example
Reactimport { BeautifulAudio } from 'beautiful-player/wrappers/react'<BeautifulAudio src="song.mp3" speeds={[1,1.5,2]} />
Vue 3import { BeautifulAudio } from 'beautiful-player/wrappers/vue'<BeautifulAudio :src="'song.mp3'" :speeds="[1,1.5,2]" />
Angularimport { BeautifulPlayerModule } from 'beautiful-player/wrappers/beautiful-player.module'<beautiful-audio src="song.mp3"></beautiful-audio>

4 · Common Props (Wrappers)

All wrappers (React, Vue, Angular) accept the same set of props/attributes. Only the syntax changes according to the framework.

PropTypeDefaultDescription / Example
srcstringAudio URL (required)
typestringMIME hint, e.g. audio/ogg
speedsnumber[][1,1.5,2]Playback rates: [1,1.25,1.5]
autoplaybooleanfalseStart playback on load
primaryColorstring#222375Brand color (background)
iconColorstring--primaryIcon/text color
iconSizenumber | string48Icon/button size (px/rem)
width/heightnumber | stringPlayer box size
hideButtons{ speed?, volume?, download? }Hide controls
icons{ play?, pause?, download?, volumeMute?, ... }built-in SVGsCustom icons (SVG, string, or imported)
tooltipsboolean | objecttruefalse disables, object allows per-button (text, HTML, React element, HTMLElement, or function)
onDownloadfunctionReceives CustomEvent<{url:string}>
Any native audio prope.g. controls, loop, preload

Example (React):

<BeautifulAudio
  src="song.mp3"
  speeds={[1, 1.25, 1.5]}
  type="audio/ogg"
  primaryColor="#222375"
  iconColor="#ff006e"
  iconSize={40}
  width={400}
  height={80}
  hideButtons={{ volume: true }}
  icons={{ play: <MyPlayIcon />, pause: '<svg>...</svg>', download: '⬇' }}
  tooltips={{ play: <strong>Play</strong>, download: 'Save file', volume: () => <span>🔊</span> }}
  controls
  preload="auto"
  onDownload={e => console.log(e.detail.url)}
/>

Example (Vue):

<BeautifulAudio
  src="song.mp3"
  :speeds="[1,1.5,2]"
  icon-color="#ff006e"
  icon-size="40"
  :icons="{ play: '<svg>...</svg>' }"
  :tooltips="{ volume: 'Volume', download: '<em>Salvar</em>' }"
  controls
  preload="auto"
  @download="handleDl"
/>

Example (Angular):

<beautiful-audio
  src="song.mp3"
  icon-size="40"
  icon-color="#ff006e"
  tooltips='{"download":"Save"}'
  hide-speed
  controls
  preload="auto"
  (download)="onDl($event)"></beautiful-audio>

Notes:

  • All wrappers forward any unknown prop/attribute to the underlying <audio> element.
  • You can use any SVG, string, or imported icon for the icons prop.
  • Tooltips accept text, HTML, React/Vue elements, HTMLElements, or functions returning any of these.
  • For advanced theming, use CSS variables (--primary, --icon-color, --btn-size) or ::part selectors (coming soon).

👨‍💻 Author

Samuel Ramos


🤝 Contributing

All contributions are welcome — from bug reports and feature requests to pull requests or documentation improvements!

How to contribute:

  • Open an issue: Found a bug, have a question, or want to suggest a feature? Open an issue.
  • Fork & PR: Fork the repo, create a branch, and submit a pull request. We review quickly!
  • Improve docs: Even typo fixes or better examples are valuable.
  • Show your work: Share your use case or integration in Discussions or via an issue.

Where to find us:

Why contribute?

  • Help shape a modern, framework-agnostic audio player for everyone.
  • Get your name in the contributors list.
  • Make open source better for the next dev!