video-dev/can-autoplay

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

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

can-autoplay.js

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

FileSize Version

Demo page

Table of contents:

Installation
install can-autoplay
Files

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.

API
audio(options)

Parameters:

Returns:

utoplay.audio().then(({result}) => {
 (result === true) {
// Can auto-play
else {
// Can not auto-play


video(options)

Parameters:

Returns:

utoplay.video().then(({result}) => {
 (result === true) {
// Can autoplay
else {
// Can not autoplay


Example
rt canAutoPlay from 'can-autoplay';

utoPlay
.video({timeout: 100, muted: true})
.then(({result, error}) => {
    if(result === false){
        console.warn('Error did occur: ', error)
    }
})
Media
Implementation Details

If it's required to have a legacy browser support you could use latest v2.x.x version of the library.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.