Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
ww_question2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
ww_question2
Commits
86ddbf38
Commit
86ddbf38
authored
Aug 14, 2020
by
liujiaxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
111ss
parent
f71d6eaf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
35 deletions
+56
-35
play.component.ts
src/app/play/play.component.ts
+56
-35
No files found.
src/app/play/play.component.ts
View file @
86ddbf38
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
{
Label
,
...
...
@@ -13,6 +22,7 @@ import {debounceTime} from 'rxjs/operators';
import
TWEEN
from
'
@tweenjs/tween.js
'
;
import
{
BehaviorSubject
}
from
'
rxjs
'
;
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 {
// 数据
data
;
constructor
()
{
constructor
(
private
appRef
:
ApplicationRef
,
private
modalService
:
NzModalService
,
private
changeDetectorRef
:
ChangeDetectorRef
)
{
this
.
rightAudio
.
src
=
'
assets/right.mp3
'
;
this
.
rightAudio
.
load
();
this
.
wrongAudio
.
src
=
'
assets/wrong.mp3
'
;
...
...
@@ -115,33 +127,33 @@ export class PlayComponent implements OnInit, OnDestroy {
ngOnInit
()
{
this
.
data
=
{
"
contentObj
"
:
{
"
title
"
:
"
ssssss
"
,
"
pic_id
"
:
"
http://staging-teach.cdn.ireadabc.com/5502addf299f5f34dc181f993f81e311.png
"
,
"
options
"
:
[{
"
text
"
:
"
111
"
,
"
pic_id
"
:
null
,
"
right
"
:
false
,
"
type
"
:
1
contentObj
:
{
title
:
'
ssssss
'
,
pic_id
:
'
http://staging-teach.cdn.ireadabc.com/5502addf299f5f34dc181f993f81e311.png
'
,
options
:
[{
text
:
'
111
'
,
pic_id
:
null
,
right
:
false
,
type
:
1
},
{
"
text
"
:
"
222
"
,
"
pic_id
"
:
null
,
"
right
"
:
true
,
"
type
"
:
1
text
:
'
222
'
,
pic_id
:
null
,
right
:
true
,
type
:
1
},
{
"
text
"
:
"
333
"
,
"
pic_id
"
:
null
,
"
right
"
:
false
,
"
type
"
:
1
text
:
'
333
'
,
pic_id
:
null
,
right
:
false
,
type
:
1
},
{
"
text
"
:
"
dddd
"
,
"
pic_id
"
:
null
,
"
right
"
:
false
,
"
type
"
:
1
text
:
'
dddd
'
,
pic_id
:
null
,
right
:
false
,
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
.
options
=
_
.
get
(
this
.
data
.
contentObj
,
'
options
'
,
[]).
map
(
item
=>
{
item
.
state
=
''
;
...
...
@@ -158,27 +170,36 @@ export class PlayComponent implements OnInit, OnDestroy {
if
(
data
&&
typeof
data
===
'
object
'
)
{
console
.
log
(
data
);
this
.
data
=
data
;
this
.
zoomIn
=
false
;
this
.
options
=
_
.
get
(
this
.
data
.
contentObj
,
'
options
'
,
[]).
map
(
item
=>
{
item
.
state
=
''
;
// Ken 2019-04-15 22:38 把showPic, showText的逻辑换为type
if
(
_
.
isUndefined
(
item
.
type
))
{
item
.
type
=
item
.
showPic
?
this
.
OPTION_TYPE
.
PIC
:
this
.
OPTION_TYPE
.
TEXT
;
}
return
item
;
});
}
this
.
zoomIn
=
false
;
this
.
options
=
_
.
get
(
this
.
data
.
contentObj
,
'
options
'
,
[]).
map
(
item
=>
{
item
.
state
=
''
;
// Ken 2019-04-15 22:38 把showPic, showText的逻辑换为type
if
(
_
.
isUndefined
(
item
.
type
))
{
item
.
type
=
item
.
showPic
?
this
.
OPTION_TYPE
.
PIC
:
this
.
OPTION_TYPE
.
TEXT
;
}
return
item
;
});
const
question_audio_id
=
_
.
get
(
this
.
data
.
contentObj
,
'
question_audio_id
'
,
null
);
// console.log('question_audio_id', question_audio_id);
this
.
questionAudio
.
src
=
question_audio_id
;
this
.
questionAudio
.
load
();
this
.
changeDetectorRef
.
markForCheck
();
this
.
changeDetectorRef
.
detectChanges
();
this
.
refresh
();
if
(
window
[
'
air
'
])
{
window
[
'
air
'
].
hideAirClassLoading
(
this
.
saveKey
,
this
.
data
);
}
},
this
.
saveKey
);
}
refresh
()
{
setTimeout
(()
=>
{
this
.
appRef
.
tick
();
},
1
);
}
ngOnDestroy
()
{
this
.
rightAudio
.
pause
();
this
.
wrongAudio
.
pause
();
...
...
@@ -218,7 +239,7 @@ export class PlayComponent implements OnInit, OnDestroy {
}
currentQuestionStatus
()
{
const
sts
=
this
.
playerState
.
asObservable
();
console
.
log
(
this
.
playerState
.
getValue
().
isPlaying
)
console
.
log
(
this
.
playerState
.
getValue
().
isPlaying
)
;
}
playQuestionAudio
(
e
)
{
e
.
stopPropagation
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment