Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 46x 6x 6x 1x 5x 4x 4x 3x 3x 3x 3x 1x | import type { Texture } from 'pixi.js';
import { decodeDDSImageData, resolveLR2AssetBytes, type LR2Skin } from '@be-music/skin-lr2';
import {
attachBlobURLToTexture,
loadVideoTexture,
loadTextureFromBytes,
registerImageDecoder,
} from '../../media/textures.ts';
// The generic image / video loaders live in `media/textures.ts`; re-export them so existing importers of this module
// (and the `@be-music/player-browser/skin` barrel) keep resolving the same symbols.
export {
attachBlobURLToTexture,
destroyTextureAndRevokeBlobURL,
loadTextureFromBytes,
loadVideoTexture,
type LoadTextureOptions,
type VideoTextureHandle,
type VideoTranscodeOptions,
} from '../../media/textures.ts';
// Browsers don't decode DDS natively, and LR2 themes like LITONE4 ship every skin texture as `.dds`. Plug the in-tree
// decoder into the shared loader at module load so every `loadTextureFromBytes` call (skin chrome, fonts, BGA) keeps
// handling the format. Unsupported DDS variants (DXT-compressed, R5G6B5, etc.) return `undefined` from the decoder and
// fall through to the blob path, which then fails gracefully.
registerImageDecoder('.dds', decodeDDSImageData);
/**
* Resolves an LR2 skin asset (image, font sheet, etc.) to a Pixi texture using the skin's bundled file map. Honors the
* skin's `#TRANSCOLOR` chroma key.
*/
export async function loadSkinAssetTexture(skin: LR2Skin, path: string): Promise<Texture | undefined> {
const bytes = resolveLR2AssetBytes(skin, path);
if (!bytes) {
return undefined;
}
if (/\.(?:mp4|m4v|webm|ogv|mpg|mpeg|wmv|avi)$/i.test(path)) {
const handle = await loadVideoTexture(path, bytes);
if (!handle) return undefined;
attachBlobURLToTexture(handle.texture, handle.objectURL);
handle.video.loop = true;
void handle.video.play().catch(() => {});
return handle.texture;
}
return loadTextureFromBytes(path, bytes, skin.transparentColor);
}
|