Jump to content

swapping video textures on sprite


lookitscook
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...