JSFiddle - React, Tailwind, and code Playground
by adil_invideo
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/pixi.js/5.3.3/pixi.min.js"></script>
<div class="title">
<div>HTML</div>
<div>PIXI</div>
</div>
<div class="parent-wrapper">
<div class="parent">
<div class="backdrop"></div>
<video id="player" controls>
<source src="https://s3.ap-south-1.amazonaws.com/invideo-block-assets/social_widgits/Twitter/eg2/twitter.webm" type="video/webm">
</video>
<!-- <img src="https://s3.ap-south-1.amazonaws.com/invideo-images/asset_snapshot_1540565522430.png" id="player"/> -->
</div>
</div>
CSS
body {
margin: 0;
display: flex;
flex-direction:column;
flex-wrap: wrap;
padding-top: 20px;
background: red;
font-family: sans-serif;
}
.parent {
width: 400px;
height: 200px;
position: relative;
}
.backdrop {
width: 100%;
height: 100%;
border: 1px dotted black;
background: white;
}
#player {
position: absolute;
bottom: 0;
left: 0;
right: 0;
width: 100%;
height: 1005;
}
.title{
display: flex;
justify-content: space-evenly;
font-size: 30px;
font-weight: 600;
}
.parent-wrapper {
display: flex;
justify-content: space-evenly;
}
JavaScript
const app = new PIXI.Application({
width: 200,
height: 100,
antialias: true,
transparent: true,
resolution: window.devicePixelRatio || 1,
})
document.getElementsByClassName("parent-wrapper")[0].appendChild(app.view);
const video = true;
var sprite = new PIXI.Sprite(PIXI.Texture.WHITE);
sprite.x = 60;
sprite.y = 0;
sprite.width = 200;
sprite.height = 200;
app.stage.addChild(sprite);
const img = new PIXI.Sprite.from("https://s3.ap-south-1.amazonaws.com/invideo-images/asset_snapshot_1540565522430.png");
img.width = 200;
img.height = 100;
// create a video texture from a path
var texture = PIXI.Texture.fromVideo('https://s3.ap-south-1.amazonaws.com/invideo-block-assets/social_widgits/Twitter/eg2/twitter.webm');
// create a new Sprite using the video texture (yes it's that easy)
var videoSprite = new PIXI.Sprite(texture);
videoSprite.width = 200;
videoSprite.height = 100;
app.stage.addChild(video ? videoSprite : img);