Helps with video playback
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example
.npmignore
LICENSE
index.js
index.mjs
package.json
readme.md
test.js

readme.md

Helps control video elements with autoplay available down to iOS 8

Setup

# Fetch latest from github
npm i thewhodidthis/playah

Usage

import createPlayer from 'playah'

const video = document.createElement('video')

'playsinline loop autoplay'.split(' ').forEach((v) => {
  video.setAttribute(v, '')
})

video.setAttribute('src', 'BigBuckBunny.mp4')

// Instantiating past video setup is
// kind of important in this example
const { play, stop } = createPlayer(video)

let paused = 1

video.addEventListener('loadstart', () => {
    paused = 0
})

video.addEventListener('click', (e) => {
    e.preventDefault()
    
    paused = paused ? play() : stop()
}, false)

document.body.appendChild(video)