如何动态用代码设置一个VideoPlayer的Clip?

资源结构如下:
image

尝试过过下面的代码:

cc.loader.loadRes(“video/mine_bg_video”, cc.Asset, function(err, clip) {
this.videoPlayer.clip = clip;
});

this.videoPlayer.clip = “resources/video/life_bg_video.mp4”;

this.videoPlayer.clip = “resources/video/life_bg_video”;

this.videoPlayer.clip = cc.url.raw(“resources/video/life_bg_video”);

this.videoPlayer.clip = cc.url.raw(“resources/video/life_bg_video.mp4”);

全部都不能设置成功, 这个clip是个string类型,那么这个clip的格式应该是什么样才是合法的?文档里没说,论坛里也搜不到,官方例子也没有.

cc.resources.load('video/mine_bg_video', (err, data)=>{
    this.videoPlayer.clip = clip;
});
1赞

createVideoPlay(video: any, callback?: Function) {

    let videoPath = "video/" + "name"+ "/" + video; 

    cc.resources.load(videoPath, cc.Asset, function (err: any, clip: any) {

        if (err) {

            console.log("视频不存在");

            return;

        }

        if (clip) {

            if (this.videoPlayer) {

                console.log("视频完整路径:" + clip)

                this.videoPlayer.clip = clip;

                this.videoPlayer.play();

                if (callback) {

                    callback();

                }

            }

        }

    }.bind(this));

}
1赞

我发的那种应该可以

谢谢,不太清楚为什么把clip设成any就行了,反正现在行了