|
@@ -17,26 +17,26 @@ function matchWare(wareList, wareId) {
|
|
|
|
|
|
class LessonScene extends scene {
|
|
class LessonScene extends scene {
|
|
constructor(scope) {
|
|
constructor(scope) {
|
|
- super(scope);
|
|
|
|
- this.timer = null; //记录定时器
|
|
|
|
- this.isBack = false; //是否返回上个场景
|
|
|
|
- this.videoPlayer = null; //视频播放器
|
|
|
|
- this.courseId = null; //记录课程ID
|
|
|
|
- this.lessonId = null; //记录课ID
|
|
|
|
- this.wareList = null; //记录课件列表
|
|
|
|
- this.curWareId = null; //当前课件的id
|
|
|
|
- this.curWareType = null; //当前课件的类型
|
|
|
|
- this.curWareIndex = 0; //当前课件在课件列表中的索引
|
|
|
|
- this.curImageList = null; //当前图片课件的图片列表
|
|
|
|
- this.curImageIndex = null;//当前图片在列表中的索引
|
|
|
|
- this.curAudioList = null; //当前音频课件的音频列表
|
|
|
|
- this.curAudioIndex = 0; //当前音频在列表中的索引
|
|
|
|
- this.videoPosition = {
|
|
|
|
- top: 270,
|
|
|
|
- left: 790,
|
|
|
|
- width: 1072,
|
|
|
|
- height: 603,
|
|
|
|
- };
|
|
|
|
|
|
+ super(scope);
|
|
|
|
+ this.timer = null; //记录定时器
|
|
|
|
+ this.isBack = false; //是否返回上个场景
|
|
|
|
+ this.videoPlayer = null; //视频播放器
|
|
|
|
+ this.courseId = null; //记录课程ID
|
|
|
|
+ this.lessonId = null; //记录课ID
|
|
|
|
+ this.wareList = null; //记录课件列表
|
|
|
|
+ this.curWareId = null; //当前课件的id
|
|
|
|
+ this.curWareType = null; //当前课件的类型
|
|
|
|
+ this.curWareIndex = 0; //当前课件在课件列表中的索引
|
|
|
|
+ this.curImageList = null; //当前图片课件的图片列表
|
|
|
|
+ this.curImageIndex = null;//当前图片在列表中的索引
|
|
|
|
+ this.curAudioList = null; //当前音频课件的音频列表
|
|
|
|
+ this.curAudioIndex = 0; //当前音频在列表中的索引
|
|
|
|
+ this.videoPosition = {
|
|
|
|
+ top: 270,
|
|
|
|
+ left: 790,
|
|
|
|
+ width: 1072,
|
|
|
|
+ height: 603,
|
|
|
|
+ };
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -111,7 +111,7 @@ class LessonScene extends scene {
|
|
case Consts.TYPE_VIDEO:
|
|
case Consts.TYPE_VIDEO:
|
|
item.icon = 'assets/img/LessonScene/video.png';
|
|
item.icon = 'assets/img/LessonScene/video.png';
|
|
break;
|
|
break;
|
|
- case Consts.TYPE_AUDIO:
|
|
|
|
|
|
+ case Consts.TYPE_AUDIOBOOK:
|
|
item.icon = 'assets/img/LessonScene/audio.png';
|
|
item.icon = 'assets/img/LessonScene/audio.png';
|
|
}
|
|
}
|
|
return `<div class="ware-item-frame">
|
|
return `<div class="ware-item-frame">
|
|
@@ -179,7 +179,7 @@ class LessonScene extends scene {
|
|
this.renderImageView();
|
|
this.renderImageView();
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
- case Consts.TYPE_AUDIO:
|
|
|
|
|
|
+ case Consts.TYPE_AUDIOBOOK:
|
|
let audioViewDom =
|
|
let audioViewDom =
|
|
`
|
|
`
|
|
<div id="view-full-screen" fe-role="Widget" class="view-full-screen-img"></div>
|
|
<div id="view-full-screen" fe-role="Widget" class="view-full-screen-img"></div>
|
|
@@ -219,17 +219,19 @@ class LessonScene extends scene {
|
|
*/
|
|
*/
|
|
renderAudioView() {
|
|
renderAudioView() {
|
|
const curAudio = this.curAudioList[this.curAudioIndex];
|
|
const curAudio = this.curAudioList[this.curAudioIndex];
|
|
- const { url, audioUrl, type } = curAudio;
|
|
|
|
|
|
+ const { img, audio, type } = curAudio;
|
|
|
|
+ let imgPath = (img || {}).path || '';
|
|
|
|
+ let audioUrl = (audio || {}).url;
|
|
let footer = document.getElementById('view-page');
|
|
let footer = document.getElementById('view-page');
|
|
if (footer) {
|
|
if (footer) {
|
|
footer.innerHTML = (this.curAudioIndex + 1) + '/' + this.curAudioList.length;
|
|
footer.innerHTML = (this.curAudioIndex + 1) + '/' + this.curAudioList.length;
|
|
}
|
|
}
|
|
let content = document.getElementById('view-content');
|
|
let content = document.getElementById('view-content');
|
|
// 1.更换背景图片
|
|
// 1.更换背景图片
|
|
- let imgHTML = `<img src="${Consts.IMG_PATH}/${url}" />`;
|
|
|
|
|
|
+ let imgHTML = `<img src="${Consts.IMG_PATH}/${imgPath}" />`;
|
|
content.innerHTML = imgHTML;
|
|
content.innerHTML = imgHTML;
|
|
// 2.根据是否有无audioURL来控制面板及audio的展现
|
|
// 2.根据是否有无audioURL来控制面板及audio的展现
|
|
- if (type === Consts.TYPE_AUDIO && audioUrl) {
|
|
|
|
|
|
+ if (type === Consts.TYPE_AUDIOBOOK && audioUrl) {
|
|
let audioElement = document.createElement('audio');
|
|
let audioElement = document.createElement('audio');
|
|
audioElement.setAttribute('id', 'courseware-audio');
|
|
audioElement.setAttribute('id', 'courseware-audio');
|
|
audioElement.setAttribute('src', audioUrl);
|
|
audioElement.setAttribute('src', audioUrl);
|
|
@@ -250,7 +252,7 @@ class LessonScene extends scene {
|
|
content.appendChild(audioElement);
|
|
content.appendChild(audioElement);
|
|
content.appendChild(controlsElement);
|
|
content.appendChild(controlsElement);
|
|
this.moye.root.reRender();
|
|
this.moye.root.reRender();
|
|
- FocusEngine.getWidgetById('audio-play').focus();
|
|
|
|
|
|
+ //FocusEngine.getWidgetById('audio-play').focus();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -335,7 +337,7 @@ class LessonScene extends scene {
|
|
this.moye.root.reRender();
|
|
this.moye.root.reRender();
|
|
this.renderImageView();
|
|
this.renderImageView();
|
|
break;
|
|
break;
|
|
- case Consts.TYPE_AUDIO:
|
|
|
|
|
|
+ case Consts.TYPE_AUDIOBOOK:
|
|
let audioViewDom =
|
|
let audioViewDom =
|
|
`
|
|
`
|
|
<div id="view-full-screen" fe-role="Widget" class="view-full-screen-img"></div>
|
|
<div id="view-full-screen" fe-role="Widget" class="view-full-screen-img"></div>
|
|
@@ -362,14 +364,6 @@ class LessonScene extends scene {
|
|
audioPlayControl(eventId) {
|
|
audioPlayControl(eventId) {
|
|
let targetAudio = document.getElementById('courseware-audio');
|
|
let targetAudio = document.getElementById('courseware-audio');
|
|
if (!targetAudio) { return; }
|
|
if (!targetAudio) { return; }
|
|
- const changeContent = () => {
|
|
|
|
- // 更换图片
|
|
|
|
- let imgDom = document.getElementById('img-wrapper');
|
|
|
|
- let curAudio = this.curAudioList[this.curAudioIndex];
|
|
|
|
- const { bgUrl, playUrl } = curAudio;
|
|
|
|
- let newImg = `<img src="${Consts.IMG_PATH}/${bgUrl}" />`
|
|
|
|
- imgDom.innerHTML = newImg;
|
|
|
|
- }
|
|
|
|
switch (eventId) {
|
|
switch (eventId) {
|
|
case 'audio-play':
|
|
case 'audio-play':
|
|
let playBtn = document.querySelector('#audio-play');
|
|
let playBtn = document.querySelector('#audio-play');
|
|
@@ -445,7 +439,7 @@ class LessonScene extends scene {
|
|
onResume(data) {
|
|
onResume(data) {
|
|
if (!data) { return; }
|
|
if (!data) { return; }
|
|
//更新下当前的课件信息
|
|
//更新下当前的课件信息
|
|
- const { curWareIndex, curImageList, curImageIndex } = data;
|
|
|
|
|
|
+ const { curWareIndex, curImageList, curImageIndex, curAudioList, curAudioIndex } = data;
|
|
this.curWareIndex = curWareIndex;
|
|
this.curWareIndex = curWareIndex;
|
|
this.curWareId = this.wareList[curWareIndex].id;
|
|
this.curWareId = this.wareList[curWareIndex].id;
|
|
this.curWareType = this.wareList[curWareIndex].type;
|
|
this.curWareType = this.wareList[curWareIndex].type;
|
|
@@ -455,6 +449,12 @@ class LessonScene extends scene {
|
|
if (curImageIndex) {
|
|
if (curImageIndex) {
|
|
this.curImageIndex = curImageIndex;
|
|
this.curImageIndex = curImageIndex;
|
|
}
|
|
}
|
|
|
|
+ if (curAudioList) {
|
|
|
|
+ this.curAudioList = curAudioList;
|
|
|
|
+ }
|
|
|
|
+ if (curAudioIndex) {
|
|
|
|
+ this.curAudioIndex = curAudioIndex;
|
|
|
|
+ }
|
|
//更新左侧焦点位置
|
|
//更新左侧焦点位置
|
|
this.moye.root.getWidgetById(`item-${this.curWareType}-${this.curWareId}-${this.curWareIndex}`).focus();
|
|
this.moye.root.getWidgetById(`item-${this.curWareType}-${this.curWareId}-${this.curWareIndex}`).focus();
|
|
//更新右侧视图
|
|
//更新右侧视图
|
|
@@ -501,6 +501,22 @@ class LessonScene extends scene {
|
|
wareList: this.wareList,
|
|
wareList: this.wareList,
|
|
curWareIndex: this.curWareIndex,
|
|
curWareIndex: this.curWareIndex,
|
|
});
|
|
});
|
|
|
|
+ } else if (this.curWareType === Consts.TYPE_AUDIOBOOK) {
|
|
|
|
+ // 全屏前移除audio标签
|
|
|
|
+ let audio = document.getElementById('courseware-audio');
|
|
|
|
+ let controls = document.querySelector('.audio-controls');
|
|
|
|
+ if (audio) {
|
|
|
|
+ document.getElementById('view-content').removeChild(audio);
|
|
|
|
+ }
|
|
|
|
+ if (controls) {
|
|
|
|
+ document.getElementById('view-content').removeChild(controls);
|
|
|
|
+ }
|
|
|
|
+ this.showScene(require('./AudioWareFullScreenScene.js'), {
|
|
|
|
+ wareList: this.wareList,
|
|
|
|
+ curWareIndex: this.curWareIndex,
|
|
|
|
+ curAudioList: this.curAudioList,
|
|
|
|
+ curAudioIndex: this.curAudioIndex,
|
|
|
|
+ });
|
|
}
|
|
}
|
|
this.postPlayRecord(this.cur_item_id, this.courseId);
|
|
this.postPlayRecord(this.cur_item_id, this.courseId);
|
|
break;
|
|
break;
|
|
@@ -509,7 +525,7 @@ class LessonScene extends scene {
|
|
this.curImageIndex -= 1;
|
|
this.curImageIndex -= 1;
|
|
this.renderImageView();
|
|
this.renderImageView();
|
|
}
|
|
}
|
|
- if (this.curWareType === Consts.TYPE_AUDIO && this.curAudioIndex - 1 >= 0) {
|
|
|
|
|
|
+ if (this.curWareType === Consts.TYPE_AUDIOBOOK && this.curAudioIndex - 1 >= 0) {
|
|
this.curAudioIndex -= 1;
|
|
this.curAudioIndex -= 1;
|
|
this.renderAudioView();
|
|
this.renderAudioView();
|
|
}
|
|
}
|
|
@@ -520,7 +536,7 @@ class LessonScene extends scene {
|
|
this.curImageIndex += 1;
|
|
this.curImageIndex += 1;
|
|
this.renderImageView();
|
|
this.renderImageView();
|
|
}
|
|
}
|
|
- if (this.curWareType === Consts.TYPE_AUDIO && this.curAudioIndex + 1 < this.curAudioList.length) {
|
|
|
|
|
|
+ if (this.curWareType === Consts.TYPE_AUDIOBOOK && this.curAudioIndex + 1 < this.curAudioList.length) {
|
|
this.curAudioIndex += 1;
|
|
this.curAudioIndex += 1;
|
|
this.renderAudioView();
|
|
this.renderAudioView();
|
|
}
|
|
}
|