lookitscook Posted April 28, 2016 Share Posted April 28, 2016 I have an application in which I need to swap in image and video content live. Currently I do this by preloading all images and using mySprite.texture = PIXI.loader.resources[imageFilename].texture; the videos will be too large to preload, so I'm trying to swap them in like so: mySprite.texture = PIXI.Texture.fromVideoUrl(videoFilename); is this the correct way to swap textures? should I be swapping in a whole new sprite or maybe just the BaseTexture? When I try and add var myOldTexture = mySprite.texture; //then I assign mySprite.texture the new content... //...and then: if(myOldTexture.baseTexture.source.play) //is video myOldTexture.texture.destroy(true) I get a repeating "Uncaught TypeError: Cannot read property 'naturalWidth' of null" error, even though the texture I've destroyed shouldn't be in use at that point, right? Quote Link to comment Share on other sites More sharing options...
lookitscook Posted May 6, 2016 Author Share Posted May 6, 2016 I solved this by changing the parent Sprite to a Container, then simply swapping in new Sprites for each video (instead of attempting to swap the texture on an existing Sprite). The old sprite (and texture, basetexture) is destroyed once the new one has been swapped in. 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.