1.2.0 • Published 5 years ago

@firstandthird/can-autoplay v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

can-autoplay.js

The auto-play feature detection in HTMLMediaElement (<audio> or <video>).

Table of contents:

Installation

npm install can-autoplay

Files

Build files are available in the dist/ directory. Bundlers will choose get the correct file chosen for them but if you just want to include it on the page, grab the dist/can-autoplay.js file.

API

audio(options)

Parameters:

  • options.inline <Boolean>, check if auto-play is possible for an inline playback, default value is false
  • options.muted <Boolean>, check if auto-play is possible for a muted content
  • options.timeout <Number>, timeout for a check, default value is 250 ms

Returns:

  • <Promise>, resoles to a <Object>:
    • result <Boolean>, true - if auto-play is possible
    • error <Error>, internal or timeout Error object
canAutoplay().then(({result}) => {
  if (result === true) {
    // Can auto-play
  } else {
    // Can not auto-play
  }
})

Media

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago