引擎版本:2.4.5
注释里面的写法会报错,具体原因未知。不得已换成了将要被废弃的loader写法
demo:
videoPlayerBug.rar (2.6 MB)
手动@引擎组
兄弟你这个路径看起来俩个不一样啊
load方法路径前为什么要加/
加/不加/都试过,没区别
测试用的~
类型改为cc.AudioClip呢
cc.AudioClip是音频。。。
// 加载资源
const resMap: Map<string, any> = new Map();
export function doLoadResources <T extends cc.Asset> (path: string, showErr: boolean = true): Promise<T | null> {
return new Promise((resolve, reject)=>{
let res = resMap.get(path);
if (res) {
resolve(res);
} else {
cc.resources.load (path, (err, res: T | null) => {
if (!err) {
res && resMap.set(path, res);
resolve(res);
} else {
showErr ? reject(err) : resolve(null);
}
})
}
});
}
export function getResources <T extends cc.Asset> (path: string): T | null {
return resMap.get(path);
}
我自己用的,不知道能不能帮到你,你那边主要是需要查一个video的类型
使用方式:
doLoadResources<cc.VideoPlayer>(path).then((video:cc.VideoPlayer)=>{
//TODO
});
也可以分开doLoadResources<cc.VideoPlayer>(path);然后需要的地方getResources<cc.VideoPlayer>(path)
把输出贴出来?只看代码一时看不出什么问题
cc.resources.load(‘video’, cc.Asset, (error, asset) => {
this.video.resourceType = cc.VideoPlayer.ResourceType.LOCAL;
this.video.clip = asset;
})
这样应该就可以了 clip 应该是cc.Asset类型的
https://github.com/cocos-creator/engine/blob/develop/cocos/video/assets/video-clip.ts 貌似develop分支上已经有了,可以自己合一下这部分代码
感谢,我试试
应该是这个问题了~~感谢
该主题在最后一个回复创建后14天后自动关闭。不再允许新的回复。