GithubHelp home page GithubHelp logo

isabella232 / simple-media-element Goto Github PK

View Code? Open in Web Editor NEW

This project forked from experience-monks/simple-media-element

0.0 0.0 0.0 5 KB

a bare-bones <audio> and <video> abstraction

License: MIT License

JavaScript 100.00%

simple-media-element's Introduction

simple-media-element

experimental

A bare-bones <audio> and <video> element abstraction. Handles mime-type lookups for common extensions and allows setting attributes via an options object.

Install

npm i simple-media-element --save

Example

const media = require('simple-media-element')

// create a new <audio> tag
const audioElement = media.audio('assets/foo.mp3', {
  loop: true,
  crossOrigin: 'Anonymous',
  volume: 0.5
})

// play the audio
audioElement.play()

// create a new <video> tag with multiple sources
const videoElement = media.video([
  'assets/video.ogv',
  'assets/video.webm'
])

Usage

NPM

element = media.video([src], [opt])

Creates a new <video> element with src, a source or array of sources. A source can be:

  • A string; in which case the mime-type is guessed from extension
  • A object with { src, type }
  • A <source> element

These are added as children to the media element.

The options given to opt. If any is unspecified, it will not be set on the element.

  • loop (Boolean)
  • muted (Boolean)
  • autoplay (Boolean)
  • controls (Boolean)
  • crossOrigin (String)
  • preload (String)
  • poster (String)
  • volume (Number)

element = media.audio([src], [opt])

The same as above, but returns a <audio> element instead.

License

MIT, see LICENSE.md for details.

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.