A Web Component to randomly change audio or video sources
MIT License
random-source
A Web Component to randomly change audio or video sources.
<script type="module" src="random-source.js"></script>
<random-source>
<audio controls>
<source src="https://darn.es/sounds/daviddarnes.m4a" />
<source src="https://darn.es/sounds/daviddarnes2.m4a" />
</audio>
</random-source>
This Web Component allows you to:
audio
or video
element once the source has endedsource
element will always be used on load, to match default behaviourYou have a few options (choose one of these):
npm install @daviddarnes/random-source
Make sure you include the <script>
in your project (choose one of these):
<!-- Host yourself -->
<script type="module" src="random-source.js"></script>
<!-- 3rd party CDN, not recommended for production use -->
<script
type="module"
src="https://www.unpkg.com/@daviddarnes/[email protected]/random-source.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: