How to use the can-autoplay.video function in can-autoplay

To help you get started, we’ve selected a few can-autoplay examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github matvp91 / indigo-player / src / utils / getEnv.ts View on Github external
export async function getEnv(config: Config): Promise {
  const userAgent: string = navigator.userAgent;

  const canAutoplay: boolean = (await canAutoplayLib.video({
    muted: config.volume === 0,
  })).result;

  const isSafari: boolean =
    /safari/i.test(userAgent) && userAgent.indexOf('Chrome') === -1;

  const isEdge: boolean = /edge/i.test(userAgent);

  const isIE: boolean =
    Boolean((window as any).ActiveXObject) ||
    /trident.*rv:1\d/i.test(userAgent);

  const isChrome: boolean = /chrome/i.test(userAgent) && !isEdge;

  const isMobile: boolean = /Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone|IEMobile|Opera Mini/i.test(
    userAgent,
github vimeo / vimeo-threejs-player / src / components / vimeo-video.js View on Github external
constructor (videoId, args = {}) {
    super()

    this.id = videoId
    this.selectedQuality = args.quality || VideoQuality.auto
    this.muted = typeof args.muted !== 'undefined' ? args.muted : false
    this.autoplay = typeof args.autoplay !== 'undefined' ? args.autoplay : true
    this.loop = typeof args.loop !== 'undefined' ? args.loop : true

    if (this.autoplay) {
      canAutoPlay.video({ muted: this.muted, timeout: 1000 }).then(({ result, error }) => {
        if (result === false) {
          console.warn('[Vimeo] Autoplay not available on this browser', error)
          this.autoplay = false

          window.addEventListener('click', this.onClickAutoplayFix.bind(this))
        }
      })
    }
  }
github GameDistribution / GD-HTML5 / src / components / VideoAd.js View on Github external
return new Promise((resolve, reject) => {
      canautoplay
        .video({ inline: true, muted: false })
        .then(({ result, error }) => {
          if (result === true)
            resolve({
              autoplayAllowed: true,
              autoplayRequiresMute: false
            });
          else
            resolve({
              autoplayAllowed: true,
              autoplayRequiresMute: true
            });
        });
    });
  }

can-autoplay

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

MIT
Latest version published 3 years ago

Package Health Score

48 / 100
Full package analysis

Popular can-autoplay functions