Jump to content

PIXI Load video fallback type


charlie_says
 Share

Recommended Posts

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!

Link to comment
Share on other sites

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)

 

 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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 :)

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...