Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
ym-23
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
ym-23
Commits
04dfe0dd
Commit
04dfe0dd
authored
Jun 08, 2020
by
Seaborn Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 标题,句子,总音频交叉点击问题
parent
08138e40
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
140 deletions
+76
-140
play.component.ts
src/app/play/play.component.ts
+76
-140
No files found.
src/app/play/play.component.ts
View file @
04dfe0dd
import
{
Component
,
ElementRef
,
ViewChild
,
OnInit
,
Input
,
OnDestroy
,
HostListener
}
from
'
@angular/core
'
;
import
{
Component
,
ElementRef
,
HostListener
,
OnDestroy
,
OnInit
,
ViewChild
}
from
'
@angular/core
'
;
import
{
res
,
resAudio
}
from
'
./resources
'
;
import
{
Subject
}
from
'
rxjs
'
;
import
{
debounceTime
,
ignoreElements
}
from
'
rxjs/operators
'
;
import
{
debounceTime
}
from
'
rxjs/operators
'
;
import
TWEEN
from
'
@tweenjs/tween.js
'
;
import
{
Label
,
MySprite
,
tweenChange
,
MyAnimation
,
randomSortByArr
,
ShapeRect
,
getMinScale
,
showPopParticle
,
moveItem
,
removeItemFromArr
,
rotateItem
,
showStar
,
showItem
,
alphaItem
,
endShow
,
hideItem
,
}
from
'
./Unit
'
;
import
{
getMinScale
,
Label
,
MySprite
,
ShapeRect
,}
from
'
./Unit
'
;
@
Component
({
...
...
@@ -82,7 +64,7 @@ export class PlayComponent implements OnInit, OnDestroy {
juziBg
:
MySprite
;
t1Bg
:
MySprite
;
Btn
sBt
n
playButto
n
juzi_bg
:
ShapeRect
;
guide_bg
:
ShapeRect
;
guide
:
MySprite
;
...
...
@@ -95,12 +77,10 @@ export class PlayComponent implements OnInit, OnDestroy {
title1
title2
bgRect
tBtn
bs
countc
=
0
;
start
=
0
;
x
firstjuzi
=
0
;
pauseButton
isFullAudioPlaying
=
false
;
lastClickedSentenceIndex
isSentencePlaying
=
false
;
@
HostListener
(
'
window:resize
'
,
[
'
$event
'
])
onResize
(
event
)
{
...
...
@@ -908,7 +888,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this
.
juziBg
=
new
MySprite
();
this
.
juziBg
.
init
(
this
.
images
.
get
(
'
juzi
'
));
// this.juziBg.x = this.canvasWidth / 2.8;
// this.juziBg.
lastClickedSentenceInde
x = this.canvasWidth / 2.8;
// this.juziBg.y = this.canvasHeight / 2 ;
const
jx
=
sx
/
1.8
;
...
...
@@ -940,23 +920,19 @@ export class PlayComponent implements OnInit, OnDestroy {
this
.
Btn
=
new
MySprite
();
this
.
tBt
n
=
new
MySprite
();
this
.
sBt
n
=
new
MySprite
();
this
.
tBt
n
.
init
(
this
.
images
.
get
(
'
stop
'
));
this
.
sBt
n
.
init
(
this
.
images
.
get
(
'
start
'
));
this
.
Btn
.
addChild
(
this
.
sBt
n
);
this
.
Btn
.
addChild
(
this
.
tBt
n
);
this
.
pauseButto
n
=
new
MySprite
();
this
.
playButto
n
=
new
MySprite
();
this
.
pauseButto
n
.
init
(
this
.
images
.
get
(
'
stop
'
));
this
.
playButto
n
.
init
(
this
.
images
.
get
(
'
start
'
));
this
.
Btn
.
addChild
(
this
.
playButto
n
);
this
.
Btn
.
addChild
(
this
.
pauseButto
n
);
this
.
juziBg
.
addChild
(
this
.
Btn
);
this
.
sBt
n
.
setScaleXY
(
this
.
mapScale
);
this
.
tBt
n
.
setScaleXY
(
this
.
mapScale
);
this
.
playButto
n
.
setScaleXY
(
this
.
mapScale
);
this
.
pauseButto
n
.
setScaleXY
(
this
.
mapScale
);
this
.
Btn
.
x
=
650
;
this
.
Btn
.
y
=
240
;
// this.tBtn.x= this.sBtn.x;
// this.tBtn.y=this.sBtn.y;
this
.
tBtn
.
alpha
=
0
;
this
.
bs
=
1
;
this
.
hide
(
this
.
pauseButton
);
if
(
this
.
data
.
wordArr
.
length
>
4
)
{
//加滚动条
...
...
@@ -1003,136 +979,87 @@ export class PlayComponent implements OnInit, OnDestroy {
return
;
}
if
(
this
.
checkClickTarget
(
this
.
sBtn
)
&&
this
.
bs
==
1
)
{
//播放键
this
.
sBtn
.
alpha
=
0
;
this
.
tBtn
.
alpha
=
1
;
this
.
bs
=
0
;
//播放所有音乐
const
audio1
=
this
.
audioObj
[
this
.
musicArr
[
0
]];
audio1
.
pause
();
audio1
.
currentTime
=
0
;
if
(
this
.
firstjuzi
==
1
)
{
console
.
log
(
"
上一次点的
"
+
this
.
x
);
const
audio1
=
this
.
audioObj
[
this
.
musicArr
[
this
.
x
]];
audio1
.
pause
();
audio1
.
currentTime
=
0
;
}
console
.
log
(
"
pic-audio
"
+
this
.
musicArr
[
1
]);
this
.
playAudio
(
this
.
musicArr
[
1
]);
this
.
start
=
1
;
if
(
this
.
checkClickTarget
(
this
.
playButton
)
&&
!
this
.
isFullAudioPlaying
)
{
//播放键
this
.
pauseSentenceAudio
();
this
.
pauseTitleAudio
();
this
.
hide
(
this
.
playButton
);
this
.
show
(
this
.
pauseButton
);
this
.
isFullAudioPlaying
=
true
;
this
.
playAudio
(
this
.
musicArr
[
1
],
false
,
()
=>
{
this
.
isFullAudioPlaying
=
false
;
this
.
hide
(
this
.
pauseButton
);
this
.
show
(
this
.
playButton
);
});
return
;
}
if
(
this
.
checkClickTarget
(
this
.
bgRect
))
{
//标题音
if
(
this
.
start
==
1
)
{
//跳转暂停
this
.
sBtn
.
alpha
=
1
;
this
.
tBtn
.
alpha
=
0
;
this
.
start
=
0
;
const
audio1
=
this
.
audioObj
[
this
.
musicArr
[
1
]];
audio1
.
pause
();
audio1
.
currentTime
=
0
;
}
if
(
this
.
firstjuzi
==
1
)
{
console
.
log
(
"
上一次点的
"
+
this
.
x
);
const
audio1
=
this
.
audioObj
[
this
.
musicArr
[
this
.
x
]];
audio1
.
pause
();
audio1
.
currentTime
=
0
;
}
this
.
pauseFullAudio
();
this
.
pauseSentenceAudio
();
this
.
playAudio
(
this
.
musicArr
[
0
]);
return
;
}
if
(
this
.
checkClickTarget
(
this
.
tBtn
)
&&
this
.
bs
==
0
)
{
//暂停键
this
.
sBtn
.
alpha
=
1
;
this
.
tBtn
.
alpha
=
0
;
this
.
bs
=
1
;
/*
const audio = this.audioObj[this.musicArr[1]];
audio.pause();
audio.currentTime = 0;*/
if
(
this
.
checkClickTarget
(
this
.
pauseButton
)
&&
this
.
isFullAudioPlaying
)
{
//暂停键
this
.
pauseAudio
(
this
.
musicArr
[
1
]);
console
.
log
(
"
结束
"
);
this
.
isFullAudioPlaying
=
false
;
this
.
show
(
this
.
playButton
);
this
.
hide
(
this
.
pauseButton
);
return
;
}
for
(
let
i
=
0
;
i
<
this
.
data
.
wordArr
.
length
;
i
++
)
{
//句子音
if
(
this
.
checkClickTarget
(
this
.
word_bg_groups
[
i
]))
{
this
.
firstjuzi
=
1
;
this
.
countc
++
;
if
(
this
.
start
==
1
)
{
//跳转暂停
this
.
sBtn
.
alpha
=
1
;
this
.
tBtn
.
alpha
=
0
;
this
.
start
=
0
;
const
audio1
=
this
.
audioObj
[
this
.
musicArr
[
1
]];
audio1
.
pause
();
audio1
.
currentTime
=
0
;
this
.
pauseFullAudio
();
this
.
pauseTitleAudio
();
this
.
pauseSentenceAudio
();
this
.
isSentencePlaying
=
true
;
this
.
lastClickedSentenceIndex
=
i
+
2
;
this
.
playAudio
(
this
.
musicArr
[
this
.
lastClickedSentenceIndex
],
true
,
()
=>
{
this
.
isSentencePlaying
=
false
;
});
return
;
}
console
.
log
(
"
contc
"
+
this
.
countc
);
console
.
log
(
"
第一次
"
);
const
audio1
=
this
.
audioObj
[
this
.
musicArr
[
0
]];
audio1
.
pause
();
audio1
.
currentTime
=
0
;
const
audio2
=
this
.
audioObj
[
this
.
musicArr
[
1
]];
audio2
.
pause
();
audio2
.
currentTime
=
0
;
}
/*
if(this.checkClickTarget(this.juzi_bg)){
//滚动区域
this.shapePosY = event.clientY;
}
*/
if
(
this
.
countc
==
1
)
{
}
}
else
{
console
.
log
(
"
this.x
"
+
this
.
x
);
const
audio
=
this
.
audioObj
[
this
.
musicArr
[
this
.
x
]];
private
pauseSentenceAudio
()
{
if
(
this
.
isSentencePlaying
)
{
const
audio
=
this
.
audioObj
[
this
.
musicArr
[
this
.
lastClickedSentenceInde
x
]];
audio
.
pause
();
audio
.
currentTime
=
0
;
}
this
.
playAudio
(
this
.
musicArr
[
i
+
2
]);
this
.
x
=
i
+
2
;
console
.
log
(
"
能点击
"
+
this
.
data
.
wordArr
[
i
].
audio_url
);
this
.
canTouch
=
true
;
return
;
}
private
pauseFullAudio
()
{
if
(
this
.
isFullAudioPlaying
)
{
this
.
show
(
this
.
playButton
);
this
.
hide
(
this
.
pauseButton
);
this
.
isFullAudioPlaying
=
false
;
const
audio
=
this
.
audioObj
[
this
.
musicArr
[
1
]];
audio
.
pause
();
}
/*
if(this.checkClickTarget(this.juzi_bg)){
//滚动区域
this.shapePosY = event.clientY;
}
*/
private
show
(
button
)
{
button
.
alpha
=
1
;
}
//音乐暂停
//音乐暂停
pauseAudio
(
key
,
callback
=
null
)
{
const
audio
=
this
.
audioObj
[
key
];
...
...
@@ -1259,4 +1186,13 @@ export class PlayComponent implements OnInit, OnDestroy {
}
private
hide
(
button
:
any
)
{
button
.
alpha
=
0
;
}
private
pauseTitleAudio
()
{
const
audio
=
this
.
audioObj
[
this
.
musicArr
[
0
]];
audio
.
pause
();
audio
.
currentTime
=
0
;
}
}
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