AmplitudeJS
repository·master·Indexed 26 days ago
https://github.com/serversideup/amplitudejsA lightweight, zero-dependency JavaScript library for creating highly customizable HTML5 media players. AmplitudeJS allows developers to design their own media controls using CSS and HTML attributes instead of relying on default browser interfaces. Key features include playlist management (next, previous, shuffle), waveform generation via the Web Audio API, live streaming support, and automatic mobile device detection for touch events.
What's inside amplitudejs
- AmplitudeJS is a lightweight, zero-dependency JavaScript library used to control the design of media controls directly within your webpage rather than relying on default browser controls. It allows for 100% customizable player elements, supports multiple playlists, autogenerates waveforms/visualizations via the Web Audio API, and supports live streaming.
Overview of Amplitude.js
masterAmplitude.js is a library that allows designers to fully control the look and feel of an HTML5 audio player using CSS and HTML attributes, bypassing the browser's default playback interface.
Key capabilities include:
- Custom Styling: Control player design by applying specific classes and/or attributes to any page elements.
- Playlist Management: Built-in support for playlist features such as
next,previous, andshuffle. - Enhanced Metadata: Support for song metadata and audio visualizations.
- Mobile Support: Automatically detects mobile devices and applies
touchstartevent listeners instead ofclickfor better responsiveness.
Understand Amplitude FX elements
masterAmplitude FX elements are specialized components used to create audio waveforms and visualizations. These elements leverage the Web Audio API to provide advanced fine-tuning capabilities and visual feedback for audio players.
Browser Support Requirements: Because FX elements rely on the Web Audio API, the user's browser must support it. Most modern browsers support this API. If the browser does not support the Web Audio API, Amplitudejs will gracefully degrade by simply not using the FX features in your player.
Configure volume increment and decrement values
masterWhen using volume increment and decrement buttons, you can specify how much the volume changes per click by using the
volume_incrementandvolume_decrementkeys in yourAmplitude.init()configuration. These values are treated as percentage adjustments. The default value for both is5.Amplitude.init({ "songs": [...], "volume_increment": 10, "volume_decrement": 10 });Display playlist metadata in the UI
masterTo automatically display playlist metadata (like
titleorauthor) in your interface, add an element to your HTML with the following attribute:data-amplitude-playlist-info="{key}"Replace
{key}with the unique key of the playlist you wish to display information for.Implement Song Buffered Progress Bars
masterAmplitudeJS uses HTML5<progress>elements to display song buffering status. You can implement four different levels of buffered progress bars depending on the scope of the data you want to display. All buffered progress elements must use the classamplitude-buffered-progress.Get AmplitudeJS support
masterDepending on your needs, you can access different levels of support:
- Community Support: Since AmplitudeJS is open source (MIT license), you can seek assistance from the community.
- Professional Support: For time-sensitive requests or direct contact with the creators, you can request professional support at https://serversideup.net/get-help/?quick_question=amplitudejs.
Install AmplitudeJS
masterAmplitudeJS can be installed using various methods. For detailed instructions, refer to the official installation documentation.Prepare the environment for the Nuxt 3 Minimal Starter
masterBefore running the application, you must create a
.envfile by copying the provided example file and filling in the required environment variables.cp .env.example .envIdentify your device and browser information
masterWhen reporting issues related to specific device or browser behavior, provide a support URL generated by whatsmybrowser.org. This provides the necessary technical details about your device to assist in troubleshooting.Configure AmplitudeJS to stop playing after a song finishes
masterBy default, AmplitudeJS automatically plays the next song in a list or playlist once the current song finishes. To prevent this behavior and stop playback entirely after a song ends, set the
continue_nextconfiguration flag tofalseduring initialization.Amplitude.init({ "songs": [...], "continue_next": false });Use AmplitudeJS elements to build your player
masterAmplitudeJS uses elements identified by classes prefixed with
amplitude-to handle audio playback controls and metadata display.- Interactive elements: Elements that trigger events (e.g.,
play,next). - Metadata elements: Elements that are automatically populated with information about the active audio (e.g., album art, song titles).
Styling Note: Most elements can be any HTML tag and can be styled via their class or specific IDs. However, the album art element must be an
<img>tag.- Interactive elements: Elements that trigger events (e.g.,