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
srcstringโ€”Audio URL
typestringโ€”MIME 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 | numberโ€”Explicit player box size
hide-buttonsstringโ€”CSV speed,volume,download
hide-speed / hide-volume / hide-downloadbooleanโ€”Individual 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
srcstringโ€”Audio URL (required)
typestringโ€”MIME 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 | stringโ€”Player 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)
onDownloadfunctionโ€”Receives CustomEvent<{url:string}>
Any native audio propโ€”โ€”e.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!