A Web Component to play audio or video with a button
MIT License
play-button
A Web Component to play audio or video with a button.
<script type="module" src="play-button.js"></script>
<play-button>
<audio controls src="https://darn.es/sounds/daviddarnes.m4a"></audio>
<button>Play</button>
</play-button>
This Web Component allows you to:
audio
or video
elements with a single button
which can play and pause the audio or videoYou have a few options (choose one of these):
npm install @daviddarnes/play-button
Make sure you include the <script>
in your project (choose one of these):
<!-- Host yourself -->
<script type="module" src="play-button.js"></script>
<!-- 3rd party CDN, not recommended for production use -->
<script type="module" src="https://www.unpkg.com/@daviddarnes/[email protected]/play-button.js"></script>
<!-- 3rd party CDN, not recommended for production use -->
<script type="module" src="https://esm.sh/@daviddarnes/[email protected]"></script>
With thanks to the following people: