Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
YM5-17
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
YM5-17
Commits
7bd290c9
Commit
7bd290c9
authored
Apr 27, 2021
by
Chen Jiping
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:增加测试代码;调整音频播放
parent
efb43eff
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
16 deletions
+35
-16
play.component.ts
src/app/play/play.component.ts
+35
-16
No files found.
src/app/play/play.component.ts
View file @
7bd290c9
...
@@ -308,6 +308,8 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -308,6 +308,8 @@ export class PlayComponent implements OnInit, OnDestroy {
const
audio
=
this
.
audioObj
[
key
];
const
audio
=
this
.
audioObj
[
key
];
if
(
audio
)
{
if
(
audio
)
{
this
.
pauseAudio
(
this
.
curAudio
);
if
(
now
)
{
if
(
now
)
{
audio
.
pause
();
audio
.
pause
();
audio
.
currentTime
=
0
;
audio
.
currentTime
=
0
;
...
@@ -319,6 +321,21 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -319,6 +321,21 @@ export class PlayComponent implements OnInit, OnDestroy {
};
};
}
}
audio
.
play
();
audio
.
play
();
this
.
curAudio
=
audio
;
return
audio
;
}
}
pauseAudio
(
audio
){
if
(
audio
)
{
if
(
this
.
listening
&&
audio
==
this
.
listening
.
audio
)
{
this
.
listening
.
pauseAudio
();
}
else
{
audio
.
pause
();
}
}
}
}
}
...
@@ -689,7 +706,7 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -689,7 +706,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this
.
startY
=
startY
;
this
.
startY
=
startY
;
this
.
initY
=
startY
;
this
.
initY
=
startY
;
let
viewHight
=
560
*
this
.
mapScale
;
let
viewHight
=
Math
.
floor
(
560
*
this
.
mapScale
)
;
const
bg
=
new
ShapeRect
();
const
bg
=
new
ShapeRect
();
bg
.
setSize
(
680
*
this
.
mapScale
,
viewHight
);
bg
.
setSize
(
680
*
this
.
mapScale
,
viewHight
);
...
@@ -701,7 +718,7 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -701,7 +718,7 @@ export class PlayComponent implements OnInit, OnDestroy {
let
y
=
0
;
let
y
=
0
;
let
dH
=
24
*
this
.
mapScale
;
let
dH
=
Math
.
floor
(
24
*
this
.
mapScale
)
;
let
totalHeight
=
0
;
let
totalHeight
=
0
;
...
@@ -745,9 +762,9 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -745,9 +762,9 @@ export class PlayComponent implements OnInit, OnDestroy {
}
}
let
scrollbar
=
new
Scrollbar
();
let
scrollbar
=
new
Scrollbar
();
scrollbar
.
init
(
this
.
mapScale
,
this
.
mapScale
,
viewHight
,
totalHeight
-
dH
,
14
);
scrollbar
.
init
(
this
.
mapScale
,
this
.
mapScale
,
viewHight
,
Math
.
floor
(
totalHeight
-
dH
)
,
14
);
scrollbar
.
showScrollbar
();
scrollbar
.
showScrollbar
();
scrollbar
.
hide
();
//
scrollbar.hide();
scrollbar
.
bg
.
x
=
this
.
canvasWidth
/
2
+
161
*
this
.
mapScale
;
scrollbar
.
bg
.
x
=
this
.
canvasWidth
/
2
+
161
*
this
.
mapScale
;
scrollbar
.
bg
.
y
=
this
.
canvasHeight
/
2
-
231
*
this
.
mapScale
;
scrollbar
.
bg
.
y
=
this
.
canvasHeight
/
2
-
231
*
this
.
mapScale
;
this
.
renderArr
.
push
(
scrollbar
.
bg
);
this
.
renderArr
.
push
(
scrollbar
.
bg
);
...
@@ -761,17 +778,15 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -761,17 +778,15 @@ export class PlayComponent implements OnInit, OnDestroy {
return
;
return
;
}
}
if
(
this
.
curAudio
)
{
if
(
this
.
curAudio
==
this
.
listening
.
audio
)
{
this
.
listening
.
pauseAudio
();
}
else
{
this
.
curAudio
.
pause
();
}
}
if
(
this
.
listening
&&
this
.
checkClickTarget
(
this
.
listening
.
bg
))
{
if
(
this
.
listening
&&
this
.
checkClickTarget
(
this
.
listening
.
bg
))
{
let
tempAudio
=
this
.
curAudio
;
if
(
tempAudio
){
tempAudio
.
pause
();
}
this
.
curAudio
=
this
.
listening
.
play
(()
=>
{
this
.
curAudio
=
this
.
listening
.
play
(()
=>
{
this
.
listening
.
reset
();
this
.
listening
.
reset
();
});
});
...
@@ -780,7 +795,11 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -780,7 +795,11 @@ export class PlayComponent implements OnInit, OnDestroy {
}
}
if
(
this
.
checkClickTarget
(
this
.
title
.
titleBg
))
{
if
(
this
.
checkClickTarget
(
this
.
title
.
titleBg
))
{
this
.
curAudio
=
this
.
title
.
playAudio
();
this
.
pauseAudio
(
this
.
curAudio
);
let
audio
=
this
.
title
.
playAudio
();
if
(
audio
){
this
.
curAudio
=
audio
;
}
return
;
return
;
}
}
...
@@ -809,7 +828,7 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -809,7 +828,7 @@ export class PlayComponent implements OnInit, OnDestroy {
if
(
this
.
checkClickTarget
(
sentenceSpr
)
&&
sentenceSpr
.
visible
&&
sentenceSpr
.
alpha
==
1
)
{
if
(
this
.
checkClickTarget
(
sentenceSpr
)
&&
sentenceSpr
.
visible
&&
sentenceSpr
.
alpha
==
1
)
{
clicked
=
true
;
clicked
=
true
;
this
.
curAudio
=
this
.
playAudio
(
sentenceSpr
.
data
.
audioUrl
,
true
);
this
.
playAudio
(
sentenceSpr
.
data
.
audioUrl
,
true
);
break
;
break
;
}
}
}
}
...
@@ -896,7 +915,7 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -896,7 +915,7 @@ export class PlayComponent implements OnInit, OnDestroy {
indexItem
.
sentence
=
sentence
;
indexItem
.
sentence
=
sentence
;
}
}
this
.
curAudio
=
this
.
playAudio
(
sentence
.
audioUrl
,
true
);
this
.
playAudio
(
sentence
.
audioUrl
,
true
);
let
spr
;
let
spr
;
...
@@ -933,7 +952,7 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -933,7 +952,7 @@ export class PlayComponent implements OnInit, OnDestroy {
let
dH
=
24
*
this
.
mapScale
;
let
dH
=
24
*
this
.
mapScale
;
console
.
log
(
offsetY
,
Math
.
floor
(
this
.
initY
),
Math
.
floor
(
this
.
initY
+
this
.
sentenceBg
.
height
))
//如果句子不在可视窗口,则进行定位滚动
//如果句子不在可视窗口,则进行定位滚动
if
(
offsetY
<
Math
.
floor
(
this
.
initY
)
||
offsetY
>=
Math
.
floor
(
this
.
initY
+
this
.
sentenceBg
.
height
)){
if
(
offsetY
<
Math
.
floor
(
this
.
initY
)
||
offsetY
>=
Math
.
floor
(
this
.
initY
+
this
.
sentenceBg
.
height
)){
...
...
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