Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video game object can't setDisplaySize #6475

Closed
rexrainbow opened this issue Apr 15, 2023 · 3 comments
Closed

Video game object can't setDisplaySize #6475

rexrainbow opened this issue Apr 15, 2023 · 3 comments

Comments

@rexrainbow
Copy link
Contributor

Version

  • Phaser Version: 3.60.0
  • Operating system: win11
  • Browser: chrome/firefox

Description

Video game object does not have frame property, thus it can't get video.frame.realWidth for setDisplaySize method

Example Test Code

From this test code,

Replace line 15 to

const intro = this.add.video(640, 360, 'spaceace').setDisplaySize(200, 200);

And it will show error message

caught TypeError: Cannot read properties of null (reading 'realWidth')
    at Video.set [as displayWidth] (Size.js:73:1)
    at Video.setDisplaySize (Size.js:181:1)
    ...

BTW, how to preload video coss-origin?
Previously, asBlob parameter seems can be used for coss-origin.

Additional Information

@photonstorm
Copy link
Collaborator

LoadURL method has crossOrigin parameter now.

@JoeSiu
Copy link

JoeSiu commented Jun 15, 2023

Facing the same issue in Phaser 3.60.0 with the video game object does not have frame property. I am using rex's UI plugin (v1.60.2) as well, and for example if I try to add a video object into a UI sizer, same error Cannot read properties of null (reading 'realWidth') at Video.get [as displayWidth] will be shown.

A temporary solution I found is to assign a random placeholder texture to the video. For example, from the same test code, add an image load to the preloader

this.load.image('placeholder', 'assets/textures/grass.png');

then replace line 15 to

const intro = this.add.video(640, 360, 'spaceace').setTexture('placeholder').setDisplaySize(200, 200);

will result in no error and the size is changed, although the size seems to be dependent to the placeholder's texture size

@rgk
Copy link
Collaborator

rgk commented Feb 10, 2024

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants