GithubHelp home page GithubHelp logo

videojs-viewability's Introduction

VideoJS Viewability

VideoJS Viewability script, allows to handle viewability for multiple videos

Demo 1

Viewability Demo 1

Demo 2

Viewability Demo 2

Usage

Step 1

Add script to your page

<script type="text/javascript" src="viewability.js"></script>

Step 2

  • Create a array to hold players that init
  • Push every player objects to players array
var players = [] // Create a array to hold players that init
function initPlayer (id) {
  /* Your Player Configuration */
  window[`quark-${id}`] = new videojs(`#${id}`, {
    techOrder: ['html5'],
    'autoplay': false
  });
  
  window[`quark-${id}`].src({
    src: 'sample.mp4',
    type: 'video/mp4'
  });

  /* Push player objects to players array on every init
     to handle viewability between each other */
  players.push(window[`quark-${id}`])
}

/* Init players */
initPlayer('player-1')
initPlayer('player-2')
initPlayer('player-3')

Step 3

Create new Viewability instance with players array

/* Init Viewability */
var viewability = new Viewability({
  players: players
})

videojs-viewability's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

videojs-viewability's Issues

What is Quark id?

Hi,

I saw something named as quark in your readme file what is it? Is it necessary to work with this repo? Why are we pushing this values to the window object? Is this library working for just names start with quark?

What about ES Modules?

I think using ES import syntax would be better than including script directly. Are you planning to add ES Modules support for this library?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.