Commit 86ddbf38 authored by liujiaxin's avatar liujiaxin

111ss

parent f71d6eaf
import {Component, ElementRef, ViewChild, OnInit, Input, OnDestroy, HostListener} from '@angular/core'; import {
Component,
ElementRef,
ViewChild,
OnInit,
Input,
OnDestroy,
HostListener,
ApplicationRef, ChangeDetectorRef
} from '@angular/core';
import * as _ from 'lodash'; import * as _ from 'lodash';
import { import {
Label, Label,
...@@ -13,6 +22,7 @@ import {debounceTime} from 'rxjs/operators'; ...@@ -13,6 +22,7 @@ import {debounceTime} from 'rxjs/operators';
import TWEEN from '@tweenjs/tween.js'; import TWEEN from '@tweenjs/tween.js';
import {BehaviorSubject} from 'rxjs'; import {BehaviorSubject} from 'rxjs';
import { animate, keyframes, state, style, transition, trigger } from '@angular/animations'; import { animate, keyframes, state, style, transition, trigger } from '@angular/animations';
import { NzModalService } from 'ng-zorro-antd';
...@@ -96,7 +106,9 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -96,7 +106,9 @@ export class PlayComponent implements OnInit, OnDestroy {
// 数据 // 数据
data; data;
constructor() { constructor(private appRef: ApplicationRef,
private modalService: NzModalService,
private changeDetectorRef: ChangeDetectorRef) {
this.rightAudio.src = 'assets/right.mp3'; this.rightAudio.src = 'assets/right.mp3';
this.rightAudio.load(); this.rightAudio.load();
this.wrongAudio.src = 'assets/wrong.mp3'; this.wrongAudio.src = 'assets/wrong.mp3';
...@@ -115,33 +127,33 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -115,33 +127,33 @@ export class PlayComponent implements OnInit, OnDestroy {
ngOnInit() { ngOnInit() {
this.data = { this.data = {
"contentObj": { contentObj: {
"title": "ssssss", title: 'ssssss',
"pic_id": "http://staging-teach.cdn.ireadabc.com/5502addf299f5f34dc181f993f81e311.png", pic_id: 'http://staging-teach.cdn.ireadabc.com/5502addf299f5f34dc181f993f81e311.png',
"options": [{ options: [{
"text": "111", text: '111',
"pic_id": null, pic_id: null,
"right": false, right: false,
"type": 1 type: 1
}, { }, {
"text": "222", text: '222',
"pic_id": null, pic_id: null,
"right": true, right: true,
"type": 1 type: 1
}, { }, {
"text": "333", text: '333',
"pic_id": null, pic_id: null,
"right": false, right: false,
"type": 1 type: 1
}, { }, {
"text": "dddd", text: 'dddd',
"pic_id": null, pic_id: null,
"right": false, right: false,
"type": 1 type: 1
}], }],
"question_audio_id": "http://staging-teach.cdn.ireadabc.com/ab0872d9ed584c06181d41d9c7c4bf75.mp3" question_audio_id: 'http://staging-teach.cdn.ireadabc.com/c203f5f5b855ba1e5f7149f91c7397ff.mp3'
}
} }
};
this.zoomIn = false; this.zoomIn = false;
this.options = _.get(this.data.contentObj, 'options', []).map(item => { this.options = _.get(this.data.contentObj, 'options', []).map(item => {
item.state = ''; item.state = '';
...@@ -158,6 +170,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -158,6 +170,8 @@ export class PlayComponent implements OnInit, OnDestroy {
if (data && typeof data === 'object') { if (data && typeof data === 'object') {
console.log(data); console.log(data);
this.data = data; this.data = data;
}
this.zoomIn = false; this.zoomIn = false;
this.options = _.get(this.data.contentObj, 'options', []).map(item => { this.options = _.get(this.data.contentObj, 'options', []).map(item => {
item.state = ''; item.state = '';
...@@ -167,18 +181,25 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -167,18 +181,25 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
return item; return item;
}); });
}
const question_audio_id = _.get(this.data.contentObj, 'question_audio_id', null); const question_audio_id = _.get(this.data.contentObj, 'question_audio_id', null);
// console.log('question_audio_id', question_audio_id); // console.log('question_audio_id', question_audio_id);
this.questionAudio.src = question_audio_id; this.questionAudio.src = question_audio_id;
this.questionAudio.load(); this.questionAudio.load();
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
if (window['air']) { if (window['air']) {
window['air'].hideAirClassLoading(this.saveKey, this.data); window['air'].hideAirClassLoading(this.saveKey, this.data);
} }
}, this.saveKey); }, this.saveKey);
} }
refresh() {
setTimeout(() => {
this.appRef.tick();
}, 1);
}
ngOnDestroy() { ngOnDestroy() {
this.rightAudio.pause(); this.rightAudio.pause();
this.wrongAudio.pause(); this.wrongAudio.pause();
...@@ -218,7 +239,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -218,7 +239,7 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
currentQuestionStatus() { currentQuestionStatus() {
const sts = this.playerState.asObservable(); const sts = this.playerState.asObservable();
console.log(this.playerState.getValue().isPlaying) console.log(this.playerState.getValue().isPlaying);
} }
playQuestionAudio(e) { playQuestionAudio(e) {
e.stopPropagation(); e.stopPropagation();
......
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