Newfangled Package Modernizer

    playah

    4.0.0 • Public • Published

    about

    Helps control video elements with autoplay available down to iOS 8.

    setup

    Download from the npm registry:

    # Add to package.json
    npm install playah

    usage

    Feed with a <video> element as for example,

    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)

    Keywords

    Install

    npm i playah

    DownloadsWeekly Downloads

    2

    Version

    4.0.0

    License

    MIT

    Unpacked Size

    5.03 MB

    Total Files

    10

    Last publish

    Collaborators

    • thewhodidthis