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

Setting displayOrigin on Video that uses loadURL makes it disappear #5560

Closed
mattjennings opened this issue Feb 12, 2021 · 3 comments
Closed

Comments

@mattjennings
Copy link
Contributor

Version

  • Phaser Version: 3.52.0
  • Operating system: macOS
  • Browser: Chrome

Description

When setting displayOrigin on a Video that is loaded with its loadURL function, it does not show up. It works if the video is loaded via key, or if setOrigin is used instead.

Example Test Code

Go to https://labs.phaser.io/edit.html?src=src/game%20objects/video/play%20video.js&v=3.52.0 and copy/paste the code below

var config = {
    type: Phaser.AUTO,
    width: 800,
    height: 600,
    backgroundColor: '#2d2d2d',
    parent: 'phaser-example',
    scene: {
        preload: preload,
        create: create
    }
};

var game = new Phaser.Game(config);


function preload ()
{
    this.load.video('wormhole', 'assets/video/wormhole.mp4', 'loadeddata', false, true);
}

function create ()
{
    var vid = this.add.video(400, 300, /* 'wormhole' */) // if key is specified and loadURL is taken out, it works
    vid.loadURL('assets/video/wormhole.mp4')
    vid.setDisplayOrigin(0, 0) // breaks video when loaded with loadURL
    
    vid.play(true);
}

Additional Information

@samme
Copy link
Contributor

samme commented Feb 13, 2021

I think if you add a video with no source you must give it a size:

var vid = this.add.video(400, 300).setSize(800, 600);

Or else wait for VIDEO_CREATED as the video has no texture frame before then.

I think the problem you saw was because setting the display origin on a size 0 game object spoils the origin values (NaN, NaN). Maybe Phaser could handle that better.

@mattjennings
Copy link
Contributor Author

Ah yes, that makes a lot of sense. I ended up waiting for the video to be created like you said.

I think even if Phaser threw a helpful warning when the result is NaN, or when it's being set before it has a size, that would be enough.

@photonstorm
Copy link
Collaborator

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

4 participants