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 file alpha on iOS #6931

Open
photonstorm opened this issue Oct 24, 2024 · 0 comments
Open

Video file alpha on iOS #6931

photonstorm opened this issue Oct 24, 2024 · 0 comments
Assignees

Comments

@photonstorm
Copy link
Collaborator

This is a multi-part issue:

  1. The Device.Video class needs to be able to detect 'mov' as an extension
  2. The Device.Video class should check for HEVC Alpha support
  3. mov files with an alpha channel don't render the alpha channel under v3.86 on iOS or macOS
  4. mov files do play on Windows, but without the alpha channel (as is expected), if you override the Device mov check
  5. Pixi 8 can play mov with alpha on iOS and doesn't appear to do anything to specifically handle this. Potentially a WebGL2 benefit? PMA? Texture update setting? See my playground here: https://www.pixiplayground.com/#/edit/WEZPQhZKnoL8aC65LFH7V

I have uploaded 2 video files that have no CORS issues here:

https://www.fatal-design.com/dog.webm
https://www.fatal-design.com/dog.mov

Code sample to test locally and against BrowserStack:

class Example extends Phaser.Scene
{
    constructor ()
    {
        super();
    }

    preload ()
    {
        this.game.device.video.mov = true;

        // this.load.video('dog', 'https://www.fatal-design.com/dog.mov');
        this.load.video('dog', 'https://www.fatal-design.com/dog.webm');
        this.load.image('bg', 'https://cdn.phaserfiles.com/v385/assets/skies/space3.png');
    }

    // HEVC with alpha is supported ONLY on Safari >=13 / ios >=13
    // previous versions also supported HEVC but WITHOUT alpha channel (video will play with black bg)
    // Safari 13 is the first version to support mediaCapabilities
    supportsHEVCAlpha ()
    {
        const navigator = window.navigator;
        const ua = navigator.userAgent.toLowerCase()
        const hasMediaCapabilities = !!(navigator.mediaCapabilities && navigator.mediaCapabilities.decodingInfo)
        const isSafari = ((ua.indexOf('safari') != -1)&& (!(ua.indexOf('chrome')!= -1) && (ua.indexOf('version/')!= -1)))

        return isSafari && hasMediaCapabilities
    }

    create ()
    {
        this.add.image(400, 300, 'bg');

        this.add.text(10, 10, 'Click for mov: ' + this.supportsHEVCAlpha(), { font: '16px Courier', fill: '#00ff00' });

        this.input.once('pointerdown', () => {

            this.add.video(512, 300, 'dog').play(true);

        });
    }
}

const config = {
    type: Phaser.AUTO,
    width: 1024,
    height: 600,
    backgroundColor: '#000000',
    scene: Example
};

let game = new Phaser.Game(config);
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

2 participants