Skip to content

Releases: jermspeaks/autoplay-detection

v0.1.2

06 Oct 21:43
Compare
Choose a tag to compare

Changelog

  • Remove node_modules from repo from previous rollup usage
  • Rollup incorrect library. Swap back to autoplay with sound
  • Bump version to 0.1.2
  • README updates

v0.1.1

06 Oct 21:17
Compare
Choose a tag to compare

Changelog

  • Add minification for production builds

v0.1.0

06 Oct 21:09
Compare
Choose a tag to compare

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);
};