Skip to content

Commit

Permalink
feat(script): 添加智慧职教音频支持
Browse files Browse the repository at this point in the history
  • Loading branch information
enncy committed Mar 20, 2023
1 parent 4204594 commit 0e6402c
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions packages/scripts/src/projects/icve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,33 +96,33 @@ export const ICVEProject = Project.create({
const win = iframe?.contentWindow;
if (win) {
const doc = win.document;
if (iframe.src.includes('content_video.action')) {
if (iframe.src.includes('content_video.action') || iframe.src.includes('content_audio.action')) {
// 视频
const video = $el<HTMLVideoElement>('video', doc);
state.study.currentMedia = video;
const media = $el<HTMLMediaElement>('video,audio', doc);
state.study.currentMedia = media;

if (video) {
if (video.ended) {
video.currentTime = 0;
if (media) {
if (media.ended) {
media.currentTime = 0;
}

video.playbackRate = this.cfg.playbackRate;
video.volume = this.cfg.volume;
media.playbackRate = this.cfg.playbackRate;
media.volume = this.cfg.volume;

await new Promise<void>((resolve, reject) => {
try {
video.addEventListener('ended', async () => {
media.addEventListener('ended', async () => {
await $.sleep(3000);
resolve();
});
video.addEventListener('pause', async () => {
if (!video.ended) {
media.addEventListener('pause', async () => {
if (!media.ended) {
await $.sleep(1000);
playMedia(() => video.play());
playMedia(() => media.play());
}
});
// 开始播放
playMedia(() => video.play());
playMedia(() => media.play());
} catch (err) {
reject(err);
}
Expand Down

0 comments on commit 0e6402c

Please sign in to comment.