video pixi v4.8.6

video pixi v4.8.6

by Bouh

HTML

<script src="https://pixijs.io/pixi-filters/tools/demo/index.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pixi.js/4.8.6/pixi.js"></script>

JavaScript

//video pixi v4.8.6

var renderer = PIXI.autoDetectRenderer(800, 600, { transparent: true });
document.body.appendChild(renderer.view);

// create the root of the scene graph
var stage = new PIXI.Container();

// create a video texture from a path
var texture = PIXI.Texture.fromVideo('https://resources.gdevelop-app.com/examples/video-player/The-Daily-Dweebs-By-Blender-Foundation-Short.mp4');

// create a new Sprite using the video texture (yes it's that easy)
var videoSprite = new PIXI.Sprite(texture);

videoSprite._texture.baseTexture.autoPlay = true;
 videoSprite._texture.baseTexture.source.preload = "auto";
  videoSprite._texture.baseTexture.source.autoload = true;

videoSprite.width = renderer.width;
videoSprite.height = renderer.height;

stage.addChild(videoSprite);

animate();

function animate(){

    // render the stage
    renderer.render(stage);

    requestAnimationFrame(animate);
}