Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
ww_listen-choose
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_listen-choose
Commits
11aaf94d
Commit
11aaf94d
authored
Oct 31, 2025
by
Jeff nan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debug
parent
80a8a613
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
13 deletions
+24
-13
play.component.ts
src/app/play/play.component.ts
+24
-13
No files found.
src/app/play/play.component.ts
View file @
11aaf94d
...
...
@@ -35,20 +35,17 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges {
saveKey
=
'
listen-choose
'
;
isPlaying
=
false
;
audio
=
n
ew
Audio
()
;
rightAudio
=
n
ew
Audio
()
;
wrongAudio
=
n
ew
Audio
()
;
audio
=
n
ull
;
rightAudio
=
n
ull
;
wrongAudio
=
n
ull
;
_lc_text
=
''
;
_data
=
[];
constructor
(
private
appRef
:
ApplicationRef
,
public
changeDetectorRef
:
ChangeDetectorRef
)
{
this
.
rightAudio
.
src
=
'
assets/right.mp3
'
;
this
.
rightAudio
.
load
();
this
.
wrongAudio
.
src
=
'
assets/wrong.mp3
'
;
this
.
wrongAudio
.
load
();
}
canPlayAudio
=
false
;
ngOnInit
()
{
this
.
data
=
{
contentObj
:
{
...
...
@@ -62,6 +59,19 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges {
}
};
window
[
'
courseware
'
].
onEvent
(
'
course-in-screen
'
,
()
=>
{
setTimeout
(()
=>
{
this
.
audio
=
new
Audio
();
this
.
audio
.
src
=
this
.
data
.
contentObj
.
audio_id
;
this
.
rightAudio
=
new
Audio
();
this
.
rightAudio
.
src
=
'
assets/right.mp3
'
;
this
.
wrongAudio
=
new
Audio
();
this
.
wrongAudio
.
src
=
'
assets/wrong.mp3
'
;
this
.
canPlayAudio
=
true
;
},
1500
);
});
// 获取数据
const
getData
=
(
window
as
any
).
courseware
.
getData
;
getData
((
data
)
=>
{
...
...
@@ -96,11 +106,9 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges {
}
playCount
=
0
;
playAudio
()
{
if
(
this
.
playCount
==
0
&&
this
.
data
.
contentObj
&&
this
.
data
.
contentObj
.
audio_id
)
{
this
.
playCount
=
1
;
this
.
audio
=
new
Audio
(
this
.
data
.
contentObj
.
audio_id
);
if
(
!
this
.
canPlayAudio
)
{
return
;
}
if
(
this
.
data
.
contentObj
&&
this
.
data
.
contentObj
.
audio_id
)
{
if
(
this
.
isPlaying
)
{
...
...
@@ -124,12 +132,15 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges {
}
handleTap
(
ev
,
item
)
{
if
(
!
this
.
canPlayAudio
)
{
return
;
}
if
(
item
.
is_right
)
{
item
.
state
=
'
right
'
;
new
Audio
(
this
.
rightAudio
.
src
+
'
?v=
'
+
new
Date
().
getTime
())
.
play
();
this
.
rightAudio
.
play
();
}
else
{
item
.
state
=
'
wrong
'
;
new
Audio
(
this
.
wrongAudio
.
src
+
'
?v=
'
+
new
Date
().
getTime
())
.
play
();
this
.
wrongAudio
.
play
();
setTimeout
(()
=>
{
item
.
state
=
''
;
},
1500
);
...
...
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