Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
@10up/component-audio
Advanced tools
NOTE: This is a very initial pass. Recommend waiting on first usage until fully tested. Updates coming shortly.
npm install --save @10up/component-audio
Clone this repo and import audio.js
and audio.css
from the dist/
directory.
The following lists the latest supported callbacks. Each callback receives an instance of the player.
Fires when the audio has been started or is no longer paused
onplay: (playerInstance) => {}
Fires when the audio/video has been paused
onpause: (playerInstance) => {}
Fires when an error occurred during the loading of an audio
onerror: (playerInstance) => {}
Fires when the browser starts looking for the audio
onloadstart: (playerInstance) => {}
Fires when the current playlist is ended
onended: (playerInstance) => {}
Fires when the audio is playing after having been paused or stopped for buffering
onplaying: (playerInstance) => {}
Fires when the browser is downloading the audio
onprogress: (playerInstance) => {}
Fires when the user starts moving/skipping to a new position in the audio
onseeking: (playerInstance) => {}
Fires when the user is finished moving/skipping to a new position in the audio
onseeked: (playerInstance) => {}
Fires when the current playback position has changed
ontimeupdate: (playerInstance) => {}
Fires when the volume has been changed
onvolumechange: (playerInstance) => {}
The following is a list of optional properties, their types and usages.
Property | Default value | Type | Usage |
---|---|---|---|
playLabel | Play | String | Label for the play button |
playLabel | Stop | String | Label for the stop button |
stopLabel | Stop | String | Label for the pause button |
pauseLabel | Pause | String | Label for the mute button |
muteLabel | Mute | String | Label for the mute button |
volumeLabel | Volume | String | Label for the volume slider |
scrubberLabel | Scrub Timeline | String | Label for the scrubber slider |
currentTimeLabel | Total Time | String | Label for the total time |
showMute | true | Boolean | Maybe show the mute button |
showStop | true | Boolean | Maybe show the stop button |
showTimer | true | Boolean | Maybe show the timer control |
showVolume | true | Boolean | Maybe show the volume slider |
showScrubber | true | Boolean | Maybe show the scrubber control |
localStorage | true | Boolean | Maybe enable localStorage. This allows a user to reload the page, and pickup where they last left off. |
debug | true | Boolean | Maybe turn on debug mode. Debug mode outputs helpful information in the console window of the browser. |
This is the markup template expected by the component. Use an HTML audio player, wrapped with an element containing a class. Here we use a div with a class of 'audio'.
<div class="audio">
<audio controls>
<source src="path/to/audio-file.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</div> <!-- //.audio -->
Create a new instance by supplying the selector to use for the audio and an object containing any necessary callback functions.
import Audio from '@10up/component-audio';
const audioInstance = new Audio( '.audio', { ...options } );
Coming soon
Coming soon
Coming soon
Active: 10up is actively working on this, and we expect to continue work for the foreseeable future including keeping tested up to the most recent version of WordPress. Bug reports, feature requests, questions, and pull requests are welcome.
FAQs
Accessible audio component.
The npm package @10up/component-audio receives a total of 4 weekly downloads. As such, @10up/component-audio popularity was classified as not popular.
We found that @10up/component-audio demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.