ceraroger Posted January 3, 2017 Share Posted January 3, 2017 Hi! I'm making nw.js application and want to use pixi.js as image and video rendering module. The "image" part goes well, but i can't get the video playing... Here's the simple code: define([ 'engine/libs/pixi/pixi.js' ], function (PIXI) { var module = { PIXI: PIXI, init: initRenderer, renderVideo: renderVideo }; function initRenderer(width, height) { var renderer = PIXI.autoDetectRenderer(width, height, {view: document.getElementById("canvas"), transparent: true}), stage = new PIXI.Container(); module.width = width; module.height = height; module.loader = new PIXI.loaders.Loader(); module.renderer = renderer; module.stage = stage; animate(); } function animate() { module.renderer.render(module.stage); requestAnimationFrame(animate); } function renderVideo(path) { if (!module.loader.resources[path]) { module.loader.add(path); module.loader.once('complete', render); module.loader.load(); } else { render(); } function render() { var texture = PIXI.Texture.fromVideo(path), video = new PIXI.Sprite(texture); video.width = module.width; video.height = module.height; module.stage.addChild(video); } } return { name: 'renderer', module: module }; }); But after video is loaded, i get Texture and VideoBaseTexture width and height = 1 and nothing happens... When i change var texture = PIXI.Texture.fromVideo(path) to var texture = PIXI.Texture.fromVideo(module.loader.resources[path]) i get an error: Uncaught TypeError: source.addEventListener is not a function. Seems like problem with html video element. I tried change video file, but it didn't help at all. Any thoughts what can be wrong? Thanks and sorry for my english! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.