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

Parser for Pixi Assets does not register properly #252

Open
adamarutyunov opened this issue Sep 13, 2023 · 2 comments
Open

Parser for Pixi Assets does not register properly #252

adamarutyunov opened this issue Sep 13, 2023 · 2 comments

Comments

@adamarutyunov
Copy link

adamarutyunov commented Sep 13, 2023

Nuxt 2.15.3 + webpack 4.47.0

Pixi version: 7.2.4
@pixi/sound version: 5.2.1

I tried to use @pixi/sound with new Pixi.Assets loading system like this:

import * as PIXI from 'pixi.js'
import '@pixi/sound'

const url = item.data.src  // path to .mp3 file
const sound = await PIXI.Assets.load(url)

I successfully load images this way, but in this example I get this error:

[Assets] <path> could not be loaded as we don't know how to parse it, ensure the correct parser has been added

Seems like LoaderParser for sound files does not add to Pixi extension system. I tried to add the extensions manually:

import {soundAsset} from '@pixi/sound/lib/soundAsset.js'
PIXI.extensions.add(soundAsset)
PIXI.extensions.add(soundAsset.loader)

But I get this error that I cannot even explain:

Error: [Loader.load] Failed to load <src>.
TypeError: Cannot read properties of undefined (reading 'useLegacy')
    at _callee2$ (Loader.ts:200:1)
    at tryCatch (Loader.js:7:1062)
    at Generator.eval (Loader.js:7:3012)
    at Generator.eval [as throw] (Loader.js:7:1699)
    at asyncGeneratorStep (Loader.js:8:103)
    at _throw (Loader.js:9:291)

Finally I gave up and used old preloading system wrapper in promise, like this:

const sound = await new Promise((resolve, reject) => {
	Sound.from({
		url,
		preload: true,
		loaded: function(err, sound) {
			resolve(sound)
		}
	})
})

But eventually I'd like to revert it back to new Assets system. Where do I do something wrong?

Also I've tried to revert to old versions of pixi.js and @pixi/sound but I kept getting same errors.

@bigtimebuddy
Copy link
Member

Can you create a minimum reproduction so that we can debug more easily? Functionally this works, as you can see the example here.

Make sure you don't have multiple copies of @pixi/core in your lock file (this can happen if you've upgraded) and could cause this behavior where the parser is getting installed in the wrong place.

@hotyes
Copy link

hotyes commented Dec 8, 2023

I had encountered same issue but solved it by adding following code manually

import { extensions } from 'pixi.js'
import { soundAsset } from '@pixi/sound'
extensions.add(soundAsset)

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