Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Lightweight Wrapper For HTML5 Media API
JavaScript CoffeeScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
dist
lib
templates
.gitignore
.npmignore
Devfile.coffee
README.md
global.js
index.js
package.json
test.js

README.md

media

Lightweight Wrapper For HTML5 Media API

media = require('media')

media.audio('song.mp3').autoplay()
media.video('totoro.mp4', document.querySelector('.foo')).autoplay()

Install

$ npm install media

Browser Compatibility

media.audio(['song.mp3', 'song.ogg']).autoplay()

Displaying Controls

parent = document.querySelector('.my-player')
media.audio(['song.mp3', 'song.ogg'], parent).autoplay.controls()

API

Example:

media.audio('foo.mp3').volume(0.3).controls().loop().on('ended', function(){
  console.log('End of the song reached')
})

Reference:

  • media(type, uri, parentElement)
  • .controls
  • .currentTime
  • .element
  • .loop
  • .muted
  • .on(event, function)
  • .pause
  • .play
  • .preload
  • .src(url)
  • .volume(number)

Events

  • abort
  • durationchange
  • ended
  • error
  • pause
  • play
  • progress
  • timeupdate

See complete reference

Something went wrong with that request. Please try again.