# simple-media-element

> a bare-bones and abstraction

Latest version **1.1.0** (published 2015-12-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install simple-media-element
pnpm add simple-media-element
yarn add simple-media-element
bun add simple-media-element
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2015-12-10 |
| First published | 2015-11-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Matt DesLauriers |
| Maintainers | mattdesl |
| Keywords | simple, media, audio, video, tag, element, elements, source, mime, type, browser, browserify, webpack |

## Links

- npm: https://www.npmjs.com/package/simple-media-element
- Repository: https://github.com/Jam3/simple-media-element
- Issues: https://github.com/Jam3/simple-media-element/issues
- npm.io page: https://npm.io/package/simple-media-element

## Dependencies (2)

- [is-dom](https://npm.io/package/is-dom.md) ^1.0.5
- [browser-media-mime-type](https://npm.io/package/browser-media-mime-type.md) ^1.0.0

## Recent versions

- 1.1.0 (latest) — 2015-12-10
- 1.0.0 — 2015-11-25

## README

# simple-media-element

[![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges)

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

## Install

```sh
npm i simple-media-element --save
```

## Example

```js
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](https://nodei.co/npm/simple-media-element.png)](https://www.npmjs.com/package/simple-media-element)

#### `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](http://github.com/Jam3/simple-media-element/blob/master/LICENSE.md) for details.

---
_Source: https://npm.io/package/simple-media-element · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
