Convert Figma logo to code with AI

DIYgod logoAPlayer

:lollipop: Wow, such a beautiful HTML5 music player

7,234
1,021
7,234
203

Top Related Projects

26,497

A simple HTML5, YouTube and Vimeo player

4,600

jPlayer : HTML5 Audio & Video for jQuery

23,915

Javascript audio library for the modern web.

22,922

HTML5 FLV Player

14,783

HLS.js is a JavaScript library that plays HLS in browsers with support for MSE.

Quick Overview

APlayer is a customizable HTML5 audio player for the browser. It provides a sleek, modern interface for playing audio files on web pages, with support for various audio formats and customization options.

Pros

  • Easy to integrate and use with minimal setup
  • Supports multiple audio formats including MP3, WAV, and OGG
  • Offers a responsive design that works well on both desktop and mobile devices
  • Provides a rich API for developers to control and customize the player

Cons

  • Limited built-in themes, requiring custom CSS for extensive visual customization
  • Lacks advanced features like equalizer or audio effects
  • May have compatibility issues with older browsers that don't support HTML5 audio

Code Examples

  1. Basic usage:
<div id="player"></div>
<script src="APlayer.min.js"></script>
<script>
    const ap = new APlayer({
        container: document.getElementById('player'),
        audio: [{
            name: 'Song Name',
            artist: 'Artist Name',
            url: 'path/to/audio.mp3',
            cover: 'path/to/cover.jpg'
        }]
    });
</script>
  1. Multiple audio tracks:
const ap = new APlayer({
    container: document.getElementById('player'),
    audio: [
        {
            name: 'Song 1',
            artist: 'Artist 1',
            url: 'path/to/song1.mp3',
            cover: 'path/to/cover1.jpg'
        },
        {
            name: 'Song 2',
            artist: 'Artist 2',
            url: 'path/to/song2.mp3',
            cover: 'path/to/cover2.jpg'
        }
    ]
});
  1. Customizing player options:
const ap = new APlayer({
    container: document.getElementById('player'),
    mini: false,
    autoplay: false,
    theme: '#FADFA3',
    loop: 'all',
    preload: 'auto',
    volume: 0.7,
    mutex: true,
    listFolded: false,
    listMaxHeight: 90,
    audio: [/* ... */]
});

Getting Started

  1. Include APlayer in your HTML file:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css">
<script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script>
  1. Create a container for the player:
<div id="aplayer"></div>
  1. Initialize APlayer with JavaScript:
const ap = new APlayer({
    container: document.getElementById('aplayer'),
    audio: [{
        name: 'Song Name',
        artist: 'Artist Name',
        url: 'path/to/audio.mp3',
        cover: 'path/to/cover.jpg'
    }]
});

Competitor Comparisons

26,497

A simple HTML5, YouTube and Vimeo player

Pros of Plyr

  • More comprehensive feature set, including support for YouTube, Vimeo, and HTML5 video/audio
  • Better documentation and examples
  • Larger community and more frequent updates

Cons of Plyr

  • Larger file size and potentially higher resource usage
  • Steeper learning curve due to more complex API

Code Comparison

APlayer:

const ap = new APlayer({
    container: document.getElementById('player'),
    audio: [{
        name: 'Song Name',
        artist: 'Artist Name',
        url: 'path/to/audio.mp3',
        cover: 'path/to/cover.jpg'
    }]
});

Plyr:

const player = new Plyr('#player', {
    controls: ['play', 'progress', 'current-time', 'mute', 'volume'],
    sources: [{
        src: 'path/to/video.mp4',
        type: 'video/mp4'
    }]
});

Summary

Plyr offers a more feature-rich and versatile media player solution with support for various platforms, while APlayer focuses primarily on audio playback with a simpler setup. Plyr's extensive documentation and active community make it suitable for complex projects, but it may be overkill for basic audio needs. APlayer provides a lightweight and easy-to-use option for audio-only applications, with a focus on simplicity and aesthetics.

4,600

jPlayer : HTML5 Audio & Video for jQuery

Pros of jPlayer

  • More mature and established project with a longer history
  • Supports a wider range of audio and video formats
  • Offers more extensive documentation and examples

Cons of jPlayer

  • Larger file size and potentially heavier on resources
  • Less modern UI design out of the box
  • Requires jQuery as a dependency

Code Comparison

APlayer:

const ap = new APlayer({
    container: document.getElementById('player'),
    audio: [{
        name: 'Song Name',
        artist: 'Artist Name',
        url: 'path/to/audio.mp3',
        cover: 'path/to/cover.jpg'
    }]
});

jPlayer:

$("#jquery_jplayer_1").jPlayer({
    ready: function () {
        $(this).jPlayer("setMedia", {
            title: "Song Name",
            mp3: "path/to/audio.mp3"
        });
    },
    swfPath: "/js",
    supplied: "mp3"
});

Both players offer simple initialization, but APlayer's syntax is more modern and concise. jPlayer requires jQuery and has a slightly more verbose setup. APlayer also includes cover art and artist information in its basic configuration, while jPlayer focuses primarily on the audio source.

23,915

Javascript audio library for the modern web.

Pros of howler.js

  • More comprehensive audio library with support for multiple audio formats
  • Better cross-browser compatibility and mobile support
  • Offers advanced features like spatial audio and audio sprites

Cons of howler.js

  • Larger file size and potentially more complex to implement
  • Less focused on providing a ready-made UI player
  • May require more custom development for visual elements

Code Comparison

APlayer:

const ap = new APlayer({
    container: document.getElementById('player'),
    audio: [{
        name: 'Song Name',
        artist: 'Artist',
        url: 'song.mp3',
        cover: 'cover.jpg'
    }]
});

howler.js:

var sound = new Howl({
  src: ['song.webm', 'song.mp3'],
  autoplay: true,
  loop: true,
  volume: 0.5,
  onend: function() {
    console.log('Finished!');
  }
});

Summary

APlayer is a lightweight, UI-focused audio player for web applications, while howler.js is a more comprehensive audio library with broader format support and advanced features. APlayer provides an easy-to-implement player interface out of the box, whereas howler.js offers more flexibility and control over audio playback but may require additional work for UI implementation.

22,922

HTML5 FLV Player

Pros of flv.js

  • Specialized for FLV video playback, offering better performance for this format
  • Supports live streaming of FLV content
  • More lightweight and focused on a specific use case

Cons of flv.js

  • Limited to FLV format, while APlayer supports multiple audio formats
  • Lacks built-in UI components, requiring more work to create a user interface
  • Does not include features like playlist management or lyrics display

Code Comparison

APlayer:

const ap = new APlayer({
    container: document.getElementById('player'),
    audio: [{
        name: 'Song Name',
        artist: 'Artist Name',
        url: 'path/to/audio.mp3',
        cover: 'path/to/cover.jpg'
    }]
});

flv.js:

if (flvjs.isSupported()) {
    var videoElement = document.getElementById('videoElement');
    var flvPlayer = flvjs.createPlayer({
        type: 'flv',
        url: 'http://example.com/flv/video.flv'
    });
    flvPlayer.attachMediaElement(videoElement);
    flvPlayer.load();
    flvPlayer.play();
}

Both libraries serve different purposes: APlayer is a more comprehensive audio player with a built-in UI, while flv.js focuses on efficient FLV video playback. The choice between them depends on the specific requirements of your project, such as the media format you need to support and the level of customization you require.

14,783

HLS.js is a JavaScript library that plays HLS in browsers with support for MSE.

Pros of hls.js

  • Specialized for HTTP Live Streaming (HLS) playback
  • Supports adaptive bitrate streaming
  • More extensive browser compatibility

Cons of hls.js

  • Limited to HLS format only
  • Requires more setup and configuration
  • Less focus on UI customization

Code Comparison

APlayer:

const ap = new APlayer({
    container: document.getElementById('player'),
    audio: [{
        name: 'Song Name',
        artist: 'Artist',
        url: 'path/to/audio.mp3',
        cover: 'path/to/cover.jpg'
    }]
});

hls.js:

var video = document.getElementById('video');
var hls = new Hls();
hls.loadSource('https://example.com/playlist.m3u8');
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, function() {
    video.play();
});

Key Differences

APlayer is a more general-purpose audio player with a focus on simplicity and UI customization. It supports various audio formats and provides an easy-to-use interface for basic audio playback needs.

hls.js, on the other hand, is specifically designed for HLS video streaming. It offers advanced features like adaptive bitrate streaming and is better suited for applications requiring live streaming or complex video delivery scenarios.

While APlayer is ideal for straightforward audio playback with a nice UI, hls.js is the go-to choice for developers needing robust HLS video streaming capabilities in web applications.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

ADPlayer

APlayer

Wow, such a lovely HTML5 music player

npm npm npm size Travis devDependency Status donate

Introduction

image

APlayer is a lovely HTML5 music player.

APlayer supports:

  • Media formats - MP4 H.264 (AAC or MP3) - WAVE PCM - Ogg Theora Vorbis
  • Features - Playlist - Lyrics

Using APlayer on your project? Let me know!

Docs

中文文档

Join the Discussion

Related Projects

Plugins

Tooling

Who use APlayer?

  • bilibili: 国内知名的视频弹幕网站
  • 黑客派: 程序员和设计师的聚集地,一个活跃的小众社区
  • 浙江大学 CC98 论坛: 浙江大学校网内规模最大的论坛,中国各大学中较活跃的 BBS 之一
  • Jelly Rue: Jelly Rue, an indie pop-rock band from Tartu.
  • Opus: An artist-exploration data visualization application
  • 站长之家: 针对中文站点提供资讯、技术、资源、服务
  • LLSupport: This site provides a lot of information about LoveLive
  • 歌词千寻: 每日更新的 LRC 歌词网站
  • iSearch: 一个提供 iTunes 搜索,试听,高清专辑封面获取,查看最新音乐动态等综合性平台
  • LRC 歌词编辑器: 一款非常实用的在线 LRC 歌词编辑器
  • Аэростатика
  • HealthDig: 每天只需两分钟的重点新闻资讯
  • Feel free to submit yours in Let me know!

Current Premium Sponsors

Special Sponsors

Contributors

This project exists thanks to all the people who contribute.

Donate

APlayer is an MIT licensed open source project and completely free to use. However, the amount of effort needed to maintain and develop new features for the project is not sustainable without proper financial backing.

You can support APlayer via donations.

Recurring Donation

One-time Donation

We accept donations via the following ways:

Author

APlayer © DIYgod, Released under the MIT License.
Authored and maintained by DIYgod with help from contributors (list).

Blog · GitHub @DIYgod · Twitter @DIYgod · Telegram Channel @awesomeDIYgod

NPM DownloadsLast 30 Days