Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mediaevents

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mediaevents

Fire events for specific timeframes easily

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

mediaEvents

:musical_note: Fire events for specific timeframes easily

Getting it

NPM:

$ npm install mediaevents

unpkg:

<script src="https://unpkg.com/mediaevents@1.0.1/mediaevents.js"></script>

Or you can go the traditional way, grab mediaevents.js from the repository and put it somewhere in your project with a <script> tag!

Usage

Text:

const media = document.getElementById('audioplayer')
const text = document.getElementById('text')

const timings = {
  "0": function() {
    text.innerHTML = 'New text at start'
  },
  "10": function() {
    document.body.style.backgroundColor = 'lightblue'
    text.innerHTML = 'New text and background color after 10 seconds'
  }
}

const ev = new mediaEvents(timings)
ev.bind(media)

Reference

new mediaEvents(timings)

  • timings: (required) Object where the keys represent the time and the values are functions or function references

mediaEvents.bind(mediaNode)

  • mediaNode: (required) media element (can be video or audio tag or anything that supplies a currentTime parameter) the events should be attached to.

Known Issues

The timeupdate event that is used by mediaEvents is not updated every millisecond or at a fixed interval, so it's not really accurate.

You can use floats as timing values, but it's not guaranteed it will make it more accurate. Seconds work just fine in all cases.

License

mediaEvents is licensed under the MIT license

Keywords

FAQs

Package last updated on 12 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc