v1.0.0 is out now!

Embed your music
beautifully anywhere.

A highly modular, lightweight Vanilla JS music player API supporting LRC lyrics synchronization, instantly convertible into various Card UI formats.

Live Playground Read Documentation

Interactive Playground

Core Settings

Card UI
bg color

Media & Metadata

Controls

Lyrics

Extended Modules

Updates dynamically

Documentation

MusicEmbedAPI Overview

MusicEmbedAPI is a lightweight, modular, client-side audio embed player built with Vanilla JavaScript (ES6).

It provides a modern music-player experience with a UI inspired by the overall experience of services such as Spotify, while remaining a standalone browser component that does not require React, Vue, or another frontend framework.

Design note: MusicEmbedAPI is inspired by modern music-streaming interfaces, with Spotify being the primary visual and UX reference. It is an independent project and is not affiliated with, endorsed by, or sponsored by Spotify.

Features

1. Three UI Types

MusicEmbedAPI provides three display modes. The default type is full.

Type Description
full Complete player with artwork, playback controls, progress bar, lyrics, artist information, credits, and sharing
track Compact music-card style component focused on the cover, title, artist, and play interaction
lyrics Large synchronized lyrics-focused component with cover, title, artist, and active-line highlighting

2. Audio Playback

The player uses the browser's native HTMLAudioElement. Supported audio sources can be any browser-compatible audio URL, such as MP3, WAV, and other formats supported by the target browser.

MusicEmbedAPI does not host or distribute audio files. You provide the audio URL through the src option.

3. Synchronized Lyrics

Lyrics can be supplied as a string in LRC format.

[00:05.20]First line of the song
[00:10.50]Second line of the song
[00:15.90]Third line of the song

The player parses the timestamps and automatically highlights the current lyric line as the audio plays. Lyrics can also automatically scroll to keep the active line visible.

4. Theme Support

The player supports dark and light modes. Dark mode is the default. The compact track and lyrics cards can also use a custom themeColor.

5. Artist Information

The full player can optionally display an artist section with an artist banner, name, verification indicator, statistics, and description.

6. Credits and Licensing

You can show production credits and a license label directly inside the full player. This is useful when distributing music or other media with attribution requirements.

7. Share Support

The full player includes sharing support through the browser's Web Share API. When Web Share is unavailable, MusicEmbedAPI falls back to copying the configured share URL to the clipboard.

8. Configurable Controls

You can disable selected controls without modifying the source code:

Requirements

MusicEmbedAPI is intended for modern browsers that support:

No frontend framework is required. No build step is required for normal browser usage.

Installation & Basic Example

MusicEmbedAPI is a browser-side JavaScript library. Place the JavaScript file in your project and load it with a normal <script> tag.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>MusicEmbedAPI Example</title>
</head>
<body>

  <div id="music-player"></div>

  <script src="./musicembed.js"></script>

  <script>
    const player = new MusicEmbed({
      type: "full",
      container: "#music-player",
      width: "100%", // Responsive width
      height: "auto",

      src: "./music/song.mp3",
      cover: "./images/cover.jpg",
      title: "My Song",
      author: "My Artist",
      mode: "dark"
    });
  </script>

</body>
</html>

Configuration Options

The constructor accepts an optional configuration object.

Option Type Default Description
type "full" | "track" | "lyrics" "full" Selects the player layout
container string "body" CSS selector for the element where the player is rendered
width string "300px" Player width (supports CSS values e.g. "100%")
height string "400px" Player height (use "auto" to prevent internal scrolling)
overflow string "hidden" Vertical overflow behavior
themeColor string "#2b4015" Background color used by compact layouts
mode "dark" | "light" "dark" Visual theme
src / cover string "" Audio file URL / Cover Image URL
title / author string "" Track title / Artist Name

Playback Control Options

MusicEmbedAPI allows specific controls to be disabled.

Option Type Effect
disableScrubbing boolean Disables manual seeking with the progress bar
disableDurationText boolean Hides current-time and duration text
disableSkip boolean Hides the previous/next seek buttons
disableShare boolean Hides the share button

Important: Skip Button Behavior

The previous/next buttons are not playlist navigation controls. They seek approximately -5 seconds (Previous) and +5 seconds (Next).

Lyrics Configuration

Provide LRC-formatted lyrics using the lyrics option. The format is [mm:ss.xx]Lyric text. Lyrics sort automatically by timestamp.

lyrics: `
[00:02.00]Welcome to the song
[00:06.50]This line appears next
[00:11.20]Now the third line is active
`

Auto Scroll: Enabled by default (autoScrollLyrics: true).

Artist & Credits

Pass an object to artistInformation and credits to display detailed track metadata and attribution inside the full player.

credits: {
  active: true,
  list: [
    { role: "Vocalist", name: "Tenxi" },
    { role: "Producer", name: "DIA" }
  ]
}

UI Types Overview

  • Full Player: Header, cover artwork, blurred background, full controls, synchronized lyrics, artist info, credits, and share button.
  • Track Card: Intentionally compact, focusing on cover art, song title, artist, and play/pause interaction.
  • Lyrics Card: Displays mini cover, track title, artist name, large lyrics, and active lyric highlighting.

Multiple Players

You can create multiple MusicEmbed instances on the same page. Each instance receives its own generated internal ID and renders into its configured container.

Note: Pressing Space toggles play/pause globally (unless typing in an input/textarea), which can affect the instance handling the shortcut.

Usage Rules & Security

Security Note: MusicEmbedAPI injects configuration values into generated HTML. Do not pass raw untrusted input directly into fields like title, author, lyrics, credits, or license. Treat them as application data and sanitize them.

CORS Considerations: Normal browser media loading rules apply. Host audio on infrastructure configured for your website, or ensure the external media host permits CORS.

Example: Complete Configuration

const player = new MusicEmbed({
  type: "full",
  container: "#music-player",
  width: "100%", // Responsive
  height: "auto", // No internal scrollbar limit
  mode: "dark",

  src: "music.mp3",
  cover: "cover.png",
  title: "Makasih Tuhan",
  author: "Tenxi",

  disableScrubbing: false,
  disableDurationText: false,
  disableSkip: false,
  disableShare: false,

  lyrics: `
[00:00.00] Intro...
[00:05.20] Lirik baris pertama
[00:10.40] Lirik baris kedua
  `,
  autoScrollLyrics: true,

  artistInformation: {
    active: true,
    banner: "cover.png",
    name: "Tenxi",
    verified: false,
    stats: "",
    description: "J4W4R4"
  },

  license: "Creative Commons Attribution 4.0",
  credits: {
    active: true,
    list: [
      { role: "Vocalist", name: "Tenxi" },
      { role: "Producer", name: "DIA" }
    ]
  },

  share: {
    title: "Dengarkan Makasih Tuhan - Tenxi",
    description: "Lagu terbaru dari Tenxi",
    url: "https://jasonpw.web.id"
  }
});

What MusicEmbedAPI Is Not

MusicEmbedAPI is not:

It is a client-side JavaScript player component. You provide the media and metadata; MusicEmbedAPI provides the player interface and playback experience.

Contributing & License

Contributions are welcome! You can contribute by reporting bugs, suggesting improvements, improving docs, accessibility, or browser compatibility, adding tests, or adding new features.

License

Copyright © 2026 JPROJECT-1. MusicEmbedAPI is licensed under the MIT License. The MIT License permits use, modification, distribution, and private or commercial use, provided that the copyright notice and license notice are retained.