charlie_says Posted January 17, 2018 Share Posted January 17, 2018 Hi, I'm just experimenting with some video in pixi. I've got the basic player working as per the example on the GoodBoy site - but, I now need to make it a bit more production ready, which means it needs to be able to handle different video types. Is there a way of setting fallback video types? (So the loader can pick the type that works in that browser?) Thanks! Quote Link to comment Share on other sites More sharing options...
charlie_says Posted January 17, 2018 Author Share Posted January 17, 2018 I tried this: this._texture = PIXI.VideoBaseTexture.fromUrls([ { src: videoNameAndPath+'.webm', mime: 'video/webm' }, { src: videoNameAndPath+'.mp4', mime: 'video/mp4' }, { src: videoNameAndPath+'.ogv', mime: 'video/ogv' } ]); let moveSprite = new PIXI.Sprite(this._texture); this.addChild(moveSprite) Which clearly is part working as I can hear the video audio playing (I guess that the video element is being loaded to the HTML for PIXI to use) but then I get this error: Uncaught TypeError: Cannot read property 'hasLoaded' of undefined at e.set (pixi.min.js:14) at new e (pixi.min.js:14) Quote Link to comment Share on other sites More sharing options...
themoonrat Posted January 17, 2018 Share Posted January 17, 2018 Could you supply an example or fiddle with which we could take a look? Quote Link to comment Share on other sites More sharing options...
charlie_says Posted January 17, 2018 Author Share Posted January 17, 2018 Thanks @themoonrat I managed to work something out: let videotexture = PIXI.VideoBaseTexture.fromUrls([ { src: videoNameAndPath+'.webm', mime: 'video/webm' }, { src: videoNameAndPath+'.mp4', mime: 'video/mp4' }, { src: videoNameAndPath+'.ogv', mime: 'video/ogv' } ]); this._texture = new PIXI.Texture(videotexture); So the fromURLs works out which type can be loaded in the browser, and then the trick is "converting" the videoTexture. I think I did try to cast it: this._texture = videotexture as PIXI.Texture; but this didn't work. Quote Link to comment Share on other sites More sharing options...
themoonrat Posted January 17, 2018 Share Posted January 17, 2018 Nopes, you've done the right thing with the fromUrls You don't want to cast it... they're different things. 'BaseTexture' and 'VideoBaseTexture' contain data about the actual image/video. A 'Texture' is some information about what part of that base image / video to use. For example, if you have a spritesheet... that whole image is the BaseTexture, but you just want to draw from certain sections of that image, and those would be the Textures pointing to different parts of the BaseTexture. So Sprites use a Texture, which contains information on how to use it's BaseTexture 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.