# canplay

> Detect whether a video element has enough data such that it can be played and render frames

Latest version **1.0.1** (published 2014-10-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install canplay
pnpm add canplay
yarn add canplay
bun add canplay
```

## 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.0.1 |
| Published | 2014-10-29 |
| First published | 2014-10-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Damon Oehlman |
| Maintainers | damonoehlman |
| Keywords | media, video, canplay |

## Links

- npm: https://www.npmjs.com/package/canplay
- Repository: https://github.com/DamonOehlman/canplay
- Issues: https://github.com/DamonOehlman/canplay/issues
- npm.io page: https://npm.io/package/canplay

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2014-10-29
- 1.0.0 — 2014-10-19

## README

# canplay

This is a super simple function designed to trigger a callback when the
supplied media element can be played.  This is particularly useful when
working with the `getUserMedia` API as capture succeeds before frames can
be rendered to the display (or captured through canvas drawing).


[![NPM](https://nodei.co/npm/canplay.png)](https://nodei.co/npm/canplay/)



## Example Usage

```js
var canplay = require('canplay');
var getUserMedia = require('getusermedia');
var attach = require('attachmediastream');

getUserMedia({ video: true, audio: false }, function(err, stream) {
  var video = (! err) && attach(stream);

  if (err) {
    return console.error(err);
  }

  canplay(video, function(err) {
    if (err) {
      return console.error(err);
    }

    console.log('ok to play');
  });
});

```

## License(s)

### ISC

Copyright (c) 2014, Damon Oehlman <damon.oehlman@gmail.com>

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.

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