Releases: jermspeaks/autoplay-detection
Releases · jermspeaks/autoplay-detection
v0.1.2
v0.1.1
Changelog
- Add minification for production builds
v0.1.0
Initial Version
Very quick and easy script to detect if autoplay with sound is working on the page
Installation
The package is bundled with UMD, so there's support for AMD, CommonJS, and RequireJS.
Example
<script src="./dist/main.min.js"></script>
Usage
The library exposes a global variable called "autoplayDetector" with a single function that returns a promise, canAutoplay
. The promise returns a Boolean
whether this browser can autoplay with sound on. The promise is rejected if the browser does not support video, or support promises, or supports proper video attributes outlined in MDN documentation.
autoplayDetector.canAutoplay().then(canUse => {
if (canUse) {
console.log('Yes, this browser can autoplay');
} else {
console.log('Nope, this browser cannot autoplay');
}
}).catch(error) {
console.log("If you're browser is this old, it needs to support video attributes.", error);
};