Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shinnn/can-play-type-to-number
Convert a value which HTMLMediaElement.canPlayType() may return into an integer: "probably" => 2, "maybe" => 1, "" => 0
https://github.com/shinnn/can-play-type-to-number
web-audio-api
Last synced: 27 days ago
JSON representation
Convert a value which HTMLMediaElement.canPlayType() may return into an integer: "probably" => 2, "maybe" => 1, "" => 0
- Host: GitHub
- URL: https://github.com/shinnn/can-play-type-to-number
- Owner: shinnn
- License: mit
- Created: 2014-07-02T14:25:26.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-08-30T01:45:17.000Z (about 6 years ago)
- Last Synced: 2024-10-01T10:02:43.730Z (about 1 month ago)
- Topics: web-audio-api
- Language: JavaScript
- Homepage:
- Size: 38.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# can-play-type-to-number
[![npm version](https://img.shields.io/npm/v/can-play-type-to-number.svg)](https://www.npmjs.com/package/can-play-type-to-number)
[![Build Status](https://travis-ci.org/shinnn/can-play-type-to-number.svg?branch=master)](https://travis-ci.org/shinnn/can-play-type-to-number)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/can-play-type-to-number.svg)](https://coveralls.io/github/shinnn/can-play-type-to-number)Convert a string which [`HTMLMediaElement.canPlayType()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/canPlayType) may returns into an integer
```javascript
canPlayTypeToNumber('probably'); //=> 2
canPlayTypeToNumber('maybe'); //=> 1
canPlayTypeToNumber(''); //=> 0canPlayTypeToNumber('perhaps'); //=> throws an error
```## Installation
[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/getting-started/what-is-npm).
```
npm install can-play-type-to-number
```## API
```javascript
import canPlayTypeToNumber from 'can-play-type-to-number';
```### canPlayTypeToNumber(*playability*)
*playability*: `string` (`'probably'`, `'maybe'`, or `''`)
Return: `integer` (`0`, `1` or `2`)| argument | return |
| ------------ | ------ |
| `'probably'` | `2` |
| `'maybe'` | `1` |
| `''` | `0` |It throws an error when the argument is not included in the list above.
## License
[MIT License](./LICENSE) © 2014 - 2018 Shinnosuke Watanabe