<audio-element>
A LitElement wrapper for the HTML <audio>
element.
Installation
yarn add @internetarchive/audio-element
Usage
import AudioELement from '@internetarchive/audio-element';
export default AudioElement;
<script type="module">
import './audio-element.js';
</script>
<audio-element></audio-element>
<script>
const audioElement = document.querySelector('audio-element');
audioElement.volume = 0.75;
audioElement.playbackRate = 0.75;
audioElement.sources = [
{url: "./spring.ogg", mimetype: "audio/ogg"}
{url: "./spring.mp3", mimetype: "audio/mpeg"}
]
audioElement.addEventListener('timeupdate', e => {
console.log('Current time has changed, new value:', e.detail.currentTime);
});
audioElement.addEventListener('durationchange', e => {
console.log('Track duration has changed, new value:', e.detail.duration);
});
audioElement.play();
audioElement.pause();
audioElement.seekTo(10);
audioElement.seekBy(10);
</script>
Development
Prerequisite
yarn install
Start Development Server
yarn start // start development server and typescript compiler
Testing
yarn test
Testing via browserstack
yarn test:bs
Demoing using storybook
yarn storybook
Linting
yarn lint