Name: can-autoplay
Owner: video-dev
Description: The auto-play feature detection in HTMLMediaElement (
Created: 2017-11-16 16:19:12.0
Updated: 2018-05-21 11:51:28.0
Pushed: 2018-02-28 01:53:15.0
Homepage: https://video-dev.github.io/can-autoplay/
Size: 167
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
The auto-play feature detection in HTMLMediaElement (<audio>
or <video>
).
Table of contents:
install can-autoplay
Build files are available in the build/
directory. Bundlers will choose get the correct file chosen for them but if you just want to include it on the page, grab the build/can-autoplay.js
file.
audio(options)
Parameters:
<Boolean>
, check if auto-play is possible for an inline playback, default value is false
<Boolean>
, check if auto-play is possible for a muted content<Number>
, timeout for a check, default value is 250
msReturns:
<Promise>
, resoles to a <Object>
:result <Boolean>
, true
- if auto-play is possibleerror <Error>
, internal or timeout Error objectutoplay.audio().then(({result}) => {
(result === true) {
// Can auto-play
else {
// Can not auto-play
video(options)
Parameters:
<Boolean>
, check if auto-play is possible for an inline playback, default value is false
<Boolean>
, check if auto-play is possible for a muted content<Number>
, timeout for a check, default value is 250
msReturns:
<Promise>
, resoles to a <Object>
:result <Boolean>
, true
- if auto-play is possibleerror <Error>
, internal or timeout Error objectutoplay.video().then(({result}) => {
(result === true) {
// Can autoplay
else {
// Can not autoplay
rt canAutoPlay from 'can-autoplay';
utoPlay
.video({timeout: 100, muted: true})
.then(({result, error}) => {
if(result === false){
console.warn('Error did occur: ', error)
}
})
audio.mp3
. Created by Weston Ruter (@westonruter). Smallest possible (<0.000001 seconds long) audio file.video.mp4
. Source: https://github.com/mathiasbynens/smallIf it's required to have a legacy browser support you could use latest v2.x.x
version of the library.