UNPKG

danmaku

Version:

Display danmaku (flying comments) on HTML5 video.

30 lines (28 loc) 766 B
import createEngine from '../engine/index.js'; import { raf } from '../utils.js'; /* eslint no-invalid-this: 0 */ export default function() { if (!this._.visible || !this._.paused) { return this; } this._.paused = false; if (this.media) { for (var i = 0; i < this._.runningList.length; i++) { var cmt = this._.runningList[i]; cmt._utc = Date.now() / 1000 - (this.media.currentTime - cmt.time); } } var that = this; var engine = createEngine( this._.engine.framing.bind(this), this._.engine.setup.bind(this), this._.engine.render.bind(this), this._.engine.remove.bind(this) ); function frame() { engine.call(that); that._.requestID = raf(frame); } this._.requestID = raf(frame); return this; }