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

Feature Request: Video autoPlay for bundle asset loading #10207

Closed
codeerspl opened this issue Feb 12, 2024 · 2 comments
Closed

Feature Request: Video autoPlay for bundle asset loading #10207

codeerspl opened this issue Feb 12, 2024 · 2 comments

Comments

@codeerspl
Copy link

Description

Hello,

It would be very good if we could define additional options when loading assets from bundles.

i.e. { alias: "Example", src: "./video.webm", options: { autoPlay: false } }

Or define the default autoPlay state for VideoResource globally.

Problem:

When loading a video via bundle, a videoResource is created with autoPlay = true.

You have to manually pause the video, but the first opportunity is only after the video is already loaded and canplaythrough = true.

The video plays for a fraction of a second before pausing. The crux of the problem lies in the video sound. You hear it for a split second and then it stops.

You can work around this by manually handling the video bundle and creating a VideoResource, but this is not the desired solution.

@bigtimebuddy
Copy link
Member

Luckily this is supported!

Here's an example.

  const texture = await PIXI.Assets.load({
    src: "https://pixijs.com/assets/video.mp4",
    alias: "video",
    data: {
      // options to be passed to VideoResource
      resourceOptions: {
        muted: true,
        autoPlay: false
      },
    },
  });

You can also set default values like this:

import { loadVideo } from 'pixi.js';

loadVideo.config.defaultMuted = true;
loadVideo.config.defaultAutoPlay = false;

See LoadVideoConfig.

@xeoshow
Copy link

xeoshow commented Apr 3, 2024

Hello @bigtimebuddy ,
It seems the example link is broken, just shows ”Sandbox not found", could you please help?
Thanks v much.

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

No branches or pull requests

3 participants