# chimee-kernel

> kernel of chimee

Latest version **1.4.0** (published 2018-01-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install chimee-kernel
pnpm add chimee-kernel
yarn add chimee-kernel
bun add chimee-kernel
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.0 |
| Published | 2018-01-17 |
| First published | 2017-07-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | songguangyu |
| Maintainers | toxicjohann, songguangyu, yandeqiang, welefen, gaoyiyi, huzunjie |
| Keywords | kernel, chimee, video |

## Links

- npm: https://www.npmjs.com/package/chimee-kernel
- Repository: https://github.com/Chimeejs/chimee-kernel
- Homepage: https://github.com/Chimeejs/chimee-kernel#readme
- Issues: https://github.com/Chimeejs/chimee-kernel/issues
- npm.io page: https://npm.io/package/chimee-kernel

## Dependencies (2)

- [babel-runtime](https://npm.io/package/babel-runtime.md) ^6.26.0
- [chimee-helper](https://npm.io/package/chimee-helper.md) ^0.2.10

## 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.4.0 (latest) — 2018-01-17
- 1.5.0-alpha (next) — 2018-04-25
- 1.3.2 — 2017-12-17
- 1.3.1 — 2017-12-17
- 1.3.0 — 2017-12-16
- 1.2.0 — 2017-12-11
- 1.1.1 — 2017-12-10
- 1.1.0 — 2017-11-25
- 1.0.15 — 2017-11-23
- 1.0.14 — 2017-11-23
- 1.0.13 — 2017-11-21
- 1.0.12 — 2017-11-10
- 1.0.11 — 2017-11-08
- 1.0.10 — 2017-11-02
- 1.0.9 — 2017-08-15
- … 8 more at https://npm.io/package/chimee-kernel/versions

## README

# chimee-kernel

Chimee-kernel is a manger of video decoder.

## Introduction

There are so many video type in the world. Each one may have its own decoder. In that case, we need a manger to handle it. In other word, we need a uniform statute.

What's more, as chimee handle most of the logic of a video player, a decoder can be just simple. It only need to provide normal function like load, play, pause etc.

In chimee, we call these decoder as `VideoKernel`. As a `VideoKernel`, it should fit rules below.

| name        | meaning                                  | type          | arguments                                | note                   |
| ----------- | ---------------------------------------- | ------------- | ---------------------------------------- | ---------------------- |
| isSupport   | A method to tell us whether the decoder can be runned in this browser | static method | none                                     | Must be a staic method |
| constructor | The constructor of `VideoKernel`, we will passed in with three arguments, an HTMLVideoElement, an Object as `KernelConfig`, another Object as `CustomConfig` | method        | videoElement: HTMLVideoElement, kernelConfig: Object, customConfig: Object |                        |
| load        | A method to load src                     | method        | src: string                              |                        |
| stopLoad    | stop the network loading                 | method        | None                                     |                        |
| startLoad   | Resume from stopLoad or any network error | method        | src: string                              |                        |
| play        | A method to play the vidoe               | method        | None                                     |                        |
| pause       | A method to pause the playing            | method        | None                                     |                        |
| refresh     | A method to reload the src               | method        | none                                     |                        |
| attachMedia |                                          | method        | none                                     |                        |
| seek        | A method to seek to a specific point     | method        | second: number                           |                        |
| destroy     | A method which will be called when we destroy the kernel | method        | none                                     |                        |
| config      | The config you stored                    | attribute     |                                          |                        |
| video       | You can store the video element here     | attribute     |                                          |                        |
| on          | A method to listen on your video kernel  | method        | type: string, handler: Function          |                        |
| off         | A method to stop listening on your video kernel | method        | type: string, handler: Function          |                        |
| once        | A method to listen on your video kernel only one time | method        | type: string, handler: Function          |                        |
| emit        | A method to emit event on your video kernel | method        | type: string, data: any                  |                        |

In nowaday, we will rebuild the video kernel when user change the src.

If you support src switch on your video kernel. Please contact us, we need to add you into whitelist.

> We may support use config on installKernel later.

## Installation

```
npm install --save chimee-kernel
```
## Usage
```javascript
import ChimeeKernel from 'chimee-kernel'

var kernel = new ChimeeKernel(document.querySelector('video'),{
    src: 'http://yunxianchang.live.ujne7.com/vod-system-bj/TL2791e64b69ea0bea234c284c694986aa.flv',
    type: 'vod',
    box: 'flv'
});

//load source
kernel.load()
```

Config:

| Field        | Type                   | Description                              |
| ------------ | ---------------------- | ---------------------------------------- |
| src          | `String`               | video source                             |
| isLive       | `Boolean`              | `'false'` or `'true'`，set video is a live stream or vod |
| box          | `String`               | Indicates stream box `'flv'` , `'hls'` , `'native'` , `'mp4'` |
| preset       | `{[string]: Function}` | set kernel decoder，example: `import chimeeKernelFlv for 'chimee-kernel-flv'; preset:{'flv': chimeeKernelFlv}` |
| presetConfig | `{[string]: Object}`   | custom config to some kernel decoder     |

Event:

| Field       | Type     | Description      |
| ----------- | -------- | ---------------- |
| `mediaInfo` | `Object` | video  mediaInfo |
| `heartbeat` | `Object` | emit per-second  |
| `error`     | `Object` | kernel error     |

Error code FLV:

| Errno | Type     | Description        |
| ----- | -------- | ------------------ |
| `100` | `Number` | NET_ERROR          |
| `101` | `Number` | CODEC_ERROR        |
| `102` | `Number` | CANNOT_SEEK        |
| `103` | `Number` | ENDOFSTREAM_ERROR  |
| `104` | `Number` | MEDIASOURCE_ERROR  |
| `105` | `Number` | SOURCEBUFFER_ERROR |
| `106` | `Number` | SBABORT_ERROR      |
| `106` | `Number` | APPENDBUFFER_ERROR |

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