[DEPRECATED] chimee-kernel has been merged into chimee.

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.

namemeaningtypeargumentsnote
isSupportA method to tell us whether the decoder can be runned in this browserstatic methodnoneMust be a staic method
constructorThe constructor of VideoKernel, we will passed in with three arguments, an HTMLVideoElement, an Object as KernelConfig, another Object as CustomConfigmethodvideoElement: HTMLVideoElement, kernelConfig: Object, customConfig: Object
loadA method to load srcmethodsrc: string
stopLoadstop the network loadingmethodNone
startLoadResume from stopLoad or any network errormethodsrc: string
playA method to play the vidoemethodNone
pauseA method to pause the playingmethodNone
refreshA method to reload the srcmethodnonenot ready to use yet
attachMediamethodnone
seekA method to seek to a specific pointmethodsecond: number
destroyA method which will be called when we destroy the kernelmethodnone
configThe config you storedattribute
videoYou can store the video element hereattribute
onA method to listen on your video kernelmethodtype: string, handler: Function
offA method to stop listening on your video kernelmethodtype: string, handler: Function
onceA method to listen on your video kernel only one timemethodtype: string, handler: Function
emitA method to emit event on your video kernelmethodtype: 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

  1. npm install --save chimee-kernel

Usage

  1. import ChimeeKernel from 'chimee-kernel'
  2. var kernel = new ChimeeKernel(document.querySelector('video'),{
  3. src: 'http://yunxianchang.live.ujne7.com/vod-system-bj/TL2791e64b69ea0bea234c284c694986aa.flv',
  4. type: 'vod',
  5. box: 'flv'
  6. });
  7. //load source
  8. kernel.load()

Config:

FieldTypeDescription
srcStringvideo source
isLiveBoolean'false' or 'true',set video is a live stream or vod
boxStringIndicates 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:

FieldTypeDescription
mediaInfoObjectvideo mediaInfo
heartbeatObjectemit per-second
errorObjectkernel error

Error code FLV:

ErrnoTypeDescription
100NumberNET_ERROR
101NumberCODEC_ERROR
102NumberCANNOT_SEEK
103NumberENDOFSTREAM_ERROR
104NumberMEDIASOURCE_ERROR
105NumberSOURCEBUFFER_ERROR
106NumberSBABORT_ERROR
106NumberAPPENDBUFFER_ERROR