1.0.1 • Published 2 years ago
webchimera-renderer v1.0.1
Renderer for WebChimera.js
Prerequisites
Install
npm install webchimera-renderer
Usage example
HTML:
<canvas id="canvas"/>JS:
var renderer = require("webchimera-renderer");
var vlc = require("wcjs-prebuilt").createPlayer();
var options = { /* Add renderer options here */ }
renderer.bind(document.getElementById("canvas"), vlc, options);
vlc.play("http://archive.org/download/CartoonClassics/Krazy_Kat_-_Keeping_Up_With_Krazy.mp4");JavaScript API
bind(canvas, vlc options): bind the Webchimera VLC player to a canvas element:canvascan be a DOM node or selector (mandatory)vlcis a VLC player created with WebChimera.js (mandatory)options:fallbackRendereris a boolean mentioning if the fallback non-WebGL renderer should be used (optional, defaults to false),preserveDrawingBufferis a boolean mentioning if we should preserve the drawing buffer (optional, defaults to false),fileModeis a boolean mentioning if we should fill canvas without re (optional, defaults to false),onFrameSetupwill be called when VLC'sonFrameSetupcallback is called, with the same arguments, after the canvas has been setup.onFrameReadywill be called when VLC'sonFrameReadycallback is called, with the same arguments, after the frame has been rendered to the canvas.onFrameCleanupwill be called when VLC'sonFrameCleanupcallback is called, with the same arguments, after the frame was cleaned up.
clear(canvas): draws a single black frame on a canvas element (it's recommended to clear the canvas when theMedia ChangedandEndedevents are triggered)getFps(function): returns int in callback, the number of frames that wore rendered in 1 seconds after the request was made (useful for performance tests and getting the current fps of a live stream as it normally returns as0with the WebChimera.js native method, to note: even when playback is paused it still renders at 10 fps)