Hi, i’m pretty new to playcanvas.
I’ve tryed to do a simple sphere with a material with a video as texture.
Everytime i try to import my video (.mp4, h264) it is shown as audio asset and not video asset.
Does anybody had this problem?
this is the script attached to the sphere:
var VideoTexture = pc.createScript(‘videoTexture’);
// attribute to hold the video asset
VideoTexture.attributes.add(‘videoAsset’, {
type: ‘asset’,
assetType: ‘video’,
title: ‘Video Asset’
});
// initialize code called once per entity
VideoTexture.prototype.initialize = function() {
var app = this.app;
var video = document.createElement(‘video’);
// If videoAsset exists, use its URL, else use the URL provided
video.src = this.videoAsset ? this.videoAsset.getFileUrl() : "https://www.solidcolor.co.uk/AdganVR/media/media_10851FF2_1CF2_7EF8_41BA_47B4A982C664_it_1.mp4";
video.crossOrigin = 'anonymous';
video.loop = true;
video.muted = true;
video.addEventListener('canplay', function (e) {
var texture = new pc.Texture(app.graphicsDevice, {
format: pc.PIXELFORMAT_R8_G8_B8,
autoMipmap: true
});
texture.setSource(video);
this.entity.model.meshInstances[0].material.diffuseMap = texture;
this.entity.model.meshInstances[0].material.update();
video.play();
}.bind(this), false);
};