Creator

VideoPlayer 远程视频 怎么预先加载

module.exports = {
//url:视频地址
//本地存放路径,传jsb.fileUtils.getWritablePath()+xx.mp4 即可
dow(url,storagePath){
    this._downloader = new jsb.Downloader();
    this._downloader.setOnFileTaskSuccess(this.onSucceed.bind(this));
    // if (onProgress != null) {
    //     this._downloader.setOnTaskProgress(this.onProgress.bind(this));
    // }
    // if (onError != null) {
    //     this._downloader.setOnTaskError(this.onError.bind(this));
    // }

    this._downloader.createDownloadFileTask(url, storagePath);
},
onSucceed(task) {
    console.log('缓存成功___')
    //task.requestURL
    //task.storagePath
    // if (cc.isValid(this._node)) {
    //     this._onSucceed(task.requestURL);
    // }
},

onProgress(task, bytesReceived, totalBytesReceived, totalBytesExpected) {
    // if (cc.isValid(this._node)) {
    //     this._onProgress(task, bytesReceived, totalBytesReceived, totalBytesExpected);
    // }
},

onError(task, errorCode, errorCodeInternal, errorStr) {
    // if (cc.isValid(this._node)) {
    //     this._onError(task, errorStr);
    // }
} }
1赞