Commit 422fc2a3 authored by liujiangnan's avatar liujiangnan

feat: 循环播放

parent cd54f7c1
......@@ -72,6 +72,7 @@ cc.Class({
name: null, // 用户取的英文名
birthday: null, // 用户的生日
courseIds: null, // 根据推荐生成的课件ID数组
currentIndex: null, // 当前进行的是courseIds里第几个课件
// 统一释放异步资源的方法
onLoad() {
......@@ -195,6 +196,7 @@ cc.Class({
return;
}
this.courseIds = res.data;
this.currentIndex = 0;
this.loadOnlineCourseWare(this.courseIds[0], false);
});
},
......@@ -495,6 +497,24 @@ cc.Class({
});
},
goNextCourseware() {
this.currentIndex ++;
if(!this.courseIds[this.currentIndex]){
this.currentIndex = 0;
}
this.callNetworkApiGet(`http://iteachabc.com`, `/api/courseware/v1/${this.courseIds[this.currentIndex]}/list`, {}, (data) => {
if (data.rows && data.rows.length > 0) {
this.courses = data.rows;
this.courseIndex = 0;
this.courseItem = data.rows[0];
this.loadPageBundle();
} else {
// 没有制作课件页,直接切换到下一个课件
this.goNextCourseware();
}
});
},
goPrePage() {
this.goTarIndexPage(this.courseIndex - 1);
},
......@@ -502,24 +522,20 @@ cc.Class({
this.goTarIndexPage(this.courseIndex + 1);
},
goTarIndexPage(index) {
if (!this.courses || index == this.courseIndex || index < 0 || index > this.courses.length - 1) {
if (!this.courses || index == this.courseIndex || index < 0 ) {
return;
}
this.showMask();
this.showWaitingLetters();
window.courseware.freeAllOcMethod();
if (index > this.courses.length - 1) {
// 本课件播放完了,切换到下一个课件
this.goNextCourseware();
return;
}
this.courseIndex = index;
this.courseItem = this.courses[this.courseIndex];
if (this.courseIndex == 0) {
cc.find('middleLayer/BtnLeft').active = false;
} else {
cc.find('middleLayer/BtnLeft').active = false;
}
if (this.courseIndex == this.courses.length - 1) {
cc.find('middleLayer/BtnRight').active = false;
} else {
// cc.find('middleLayer/BtnRight').active = true;
}
this.loadPageBundle();
},
log(str) {
......@@ -558,6 +574,7 @@ cc.Class({
courseItem: null,
loadOnlineCourseWare(courseId, linkFlag) {
this.hideUI();
this.showMask();
this.showWaitingLetters();
let api = `/api/courseware/v1/${courseId}/list`;
......@@ -622,8 +639,6 @@ cc.Class({
},
loadBundle(sceneName, version, bondleUrl) {
this.currentBundleInfo = { sceneName, version, bondleUrl };
this.showMask();
this.showWaitingLetters();
cc.assetManager.loadBundle(bondleUrl, { version: version }, async (err, bundle) => {
if (err) {
return this.asyncDelayLog(err);
......@@ -648,11 +663,6 @@ cc.Class({
});
},
reloadBundle() {
const { sceneName, version, bondleUrl } = this.currentBundleInfo;
this.loadBundle(sceneName, version, bondleUrl);
},
showMask() {
const mask = cc.find('middleLayer/mask');
mask.active = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment