Jump to content

Video playback problem


ceraroger
 Share

Recommended Posts

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! :)

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...