An audio custom web component built with the native customElements.define function and on top of the HTML Audio element. No javascript library or framework attached.
Check out a live demo here.
npm install audio-tool
- Inject in the script through a script tag in the HEAD of your index.html.
<script src="node_modules/audio-tool/dist/audio-tool.min.js"></script>
- Start using it in an html file.
<audio-tool src="content/ff7-prelude.m4a" title="FF7 Prelude"></audio-tool>
Using a browser that doesn't natively support custom web components?
Add the following to the HEAD of your index.html.
<script src="https://unpkg.com/@webcomponents/custom-elements"></script>
or go here to learn more...
Add the following meta tag for responsiveness across all devices.
This tag is not specific to this component. This is required for any app to understand the screen size in mobile browsers.
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=yes" />
Attribute | type | Description | Default |
---|---|---|---|
src | string | the path to your audio file | none |
title | string | Define the track title. | The path to your audio file |
auto-play | boolean | Automatically start playing the track onload | false |
styles | boolean | Defines whether the element uses the default styles or not. | true |
preload | string: auto , metadata , none |
Defines if the audio file should be loaded when the page loads | auto |
Note: The preload attribute is ignored if autoplay is present.
Mozilla Browser Compatibility Table for customElements.define