import { Store } from '../stores/store'; import * as PIXI from 'pixi.js'; import type * as types from '../types/data'; export interface MediaItem { src: string; target: HTMLVideoElement | Howl; trackIndex: number; waitingFun: () => void; canplayFun: () => void; } export interface GIFItem { totalFrame: number; delayFrame: number; width: number; height: number; drawFrame: (n: number) => void; destroy: () => void; } /** * 资源管理器 * 所有用到的资源都会从资源管理器中获取 * 另外资源管理器会对资源进行详细的分类处理 * 对资源的操作都是通过id */ export declare class ResourceManage { private _store; private _resourceHost; set resourceHost(s: string); get resourceHost(): string; constructor(store: Store); tempData: Record; /** * 设置内存数据 * @param key 键值 * @param data 数据 */ setTempData(key: string, data: any): void; /** * 获取内存缓存数据 * @param key 键值 * @returns any */ getTempData(key: string): any; /** * 通过键值移除内存缓存数据 * @param key */ removeTempData(key: string): void; /** * 资源缓存 * @param url */ cacheMedia(url: string, type?: 'audio' | 'video'): Promise; /** * 删除缓存数据,如果有销毁方法,要调用销毁 */ clearTempData(): void; /** * 缓存的blob_url * { url: blobURL } * 图片的URL: blobURL */ private _cacheBolbURL; getCachedBlobUrl(url: string): any; /** * video, audio 缓存 * src 不带 resourceHost */ medias: Record; /** * 轨道上用到的媒体资源 * clone this.medias来的 * string: ${trackIndex}_${videoSrc} */ trackMedias: Record; get img404(): any; /** * 移除轨道的时候调用 * @param trackIndex * @param resourceId * @returns true 表示找到并删了 */ removeTrackMedias(trackIndex: number, resourceId: string): boolean; /** * 移除未使用的缓存数据 */ removeUnuesdCache(): types.Resource[]; getBlobURLBySourceId(sourceId: string): any; /** * 通过资源ID获取缓存资源 * @param sourceId * @returns */ getCacheItemBySourceId(sourceId: string): { resource: types.Resource; url: string; bolbURL: any; }; reURL(url: string): string; /** * 获取本地资源的URL * @param url * @returns */ getMaterialFileUrl: (url: string) => Promise; /** * fetch封装 * 将url完全加载然后缓存成blobURL */ fetchBlob(url: string, onProgress?: (n: number) => void): Promise; /** * 加载已使用的资源 * @param onProgress 进度回调 * @param limitPromise 限制同步加载数量,浏览器一般不能一次性加载太多资源,会导致资源异常,默认限制只能一次性加载10个资源 */ loadUsedResource(onProgress: (n: number) => void, fetchSourceBeforeRender: boolean, // 该参数如果是true,全部资源都会做blob limitPromise?: number, env?: types.Env): Promise; /** * 通过id获取原始资源 * @param resourceId * @returns */ getResouceById(resourceId: string): types.Resource | undefined; /** * 获取texture纹理 * @param resourceId * @returns */ getTextureById(resourceId: string): Promise>; /** * 从缓存中获取资源,如果没有blob就会返回url * @param resourceId * @returns */ getCacheBlobURLById(resourceId: string, trackIndex?: number): string | MediaItem | Blob; /** * 从data中获取已使用的资源,返回资源对象 */ getUsedResource(): types.Resource[] | null; clearAllTrackMedias(): void; destroy: () => void; /** * 解析 APNG,等待所有帧全部解析完成 * @param {string} url APNG 地址 * @returns {Promise<{totalFrames: number, done: boolean}>} */ loadAPNGAllFrames(url: string): Promise<{ totalFrames: number; parsedFrames: number; done: boolean; }>; }