Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SSIWB2504
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
SSIWB2504
Commits
5639b3a2
Commit
5639b3a2
authored
Aug 23, 2025
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(play): 修复音频播放问题并更新默认音频URL
parent
d64bc800
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
11 deletions
+15
-11
play.component.ts
src/app/play/play.component.ts
+15
-11
No files found.
src/app/play/play.component.ts
View file @
5639b3a2
...
...
@@ -56,7 +56,7 @@ let defaultFormData: FormData = {
imgSize
:
'
big
'
,
"
questions
"
:
[
{
"
type
"
:
"
txt
"
,
"
audio
"
:
"
http
://staging-teach.cdn.ireadabc.com/736c616e8b66a3ae03c8e8636ca46f0f
.mp3
"
,
"
text
"
:
""
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/bde25b1b2a7fdf976f17ae80b6a20a25.png
"
,
"
time
"
:
null
,
"
duration
"
:
""
,
"
audioName
"
:
""
,
"
imgSize
"
:
"
big
"
"
type
"
:
"
txt
"
,
"
audio
"
:
"
http
s://staging-teach.cdn.ireadabc.com/a050401ba53e74ede17b5c49635a977a
.mp3
"
,
"
text
"
:
""
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/bde25b1b2a7fdf976f17ae80b6a20a25.png
"
,
"
time
"
:
null
,
"
duration
"
:
""
,
"
audioName
"
:
""
,
"
imgSize
"
:
"
big
"
},
{
"
type
"
:
"
img
"
,
"
imgSize
"
:
"
big
"
,
"
audio
"
:
"
http://staging-teach.cdn.ireadabc.com/89060c9eddd5f0f67908cce77ee74f94.mp3
"
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/761e1b17e16fa4674db9ad5344676bb9.png
"
,
"
time
"
:
null
,
"
audioName
"
:
""
},
{
...
...
@@ -1014,10 +1014,12 @@ export class PlayComponent implements OnInit, OnDestroy {
if
(
currentQuestion
.
correctQuestion
&&
currentQuestion
.
correctQuestion
.
audio
)
{
if
((
this
.
g_formData
.
doubleModal
||
this
.
currentStageIndex
!==
0
))
{
setTimeout
(()
=>
{
this
.
g_cartoon
.
playAudio
(
currentQuestion
.
correctQuestion
.
audio
);
this
.
g_cartoon
.
stopAllAudio
();
this
.
g_cartoon
.
playAudio
(
currentQuestion
.
correctQuestion
.
audio
,
true
);
},
500
);
}
else
{
this
.
g_cartoon
.
playAudio
(
currentQuestion
.
correctQuestion
.
audio
);
this
.
g_cartoon
.
stopAllAudio
();
this
.
g_cartoon
.
playAudio
(
currentQuestion
.
correctQuestion
.
audio
,
true
);
}
}
}
...
...
@@ -1059,7 +1061,8 @@ export class PlayComponent implements OnInit, OnDestroy {
const
currentStage
=
this
.
gameStages
[
this
.
currentStageIndex
];
if
(
currentStage
&&
currentStage
.
correctQuestion
&&
currentStage
.
correctQuestion
.
audio
)
{
// 播放当前正确问题的音频
this
.
g_cartoon
.
playAudio
(
currentStage
.
correctQuestion
.
audio
);
this
.
g_cartoon
.
stopAllAudio
();
this
.
g_cartoon
.
playAudio
(
currentStage
.
correctQuestion
.
audio
,
true
);
}
// 注销该鱼的点击事件
this
.
unsubscribeFishEvent
(
fish
.
fishId
);
...
...
@@ -1931,7 +1934,8 @@ export class PlayComponent implements OnInit, OnDestroy {
console
.
log
(
"
btn_fa_yin
"
,
currentStage
)
if
(
currentStage
&&
currentStage
.
correctQuestion
&&
currentStage
.
correctQuestion
.
audio
)
{
// 播放当前正确问题的音频
this
.
g_cartoon
.
playAudio
(
currentStage
.
correctQuestion
.
audio
);
this
.
g_cartoon
.
stopAllAudio
();
this
.
g_cartoon
.
playAudio
(
currentStage
.
correctQuestion
.
audio
,
true
);
}
})
}
...
...
@@ -2848,15 +2852,15 @@ export class PlayComponent implements OnInit, OnDestroy {
// 帧率控制:计算当前时间与上一帧时间的差值
const
currentTime
=
Date
.
now
();
const
elapsed
=
currentTime
-
this
.
m_lastFrameTime
;
// 计算时间增量(秒)
const
dt
=
elapsed
/
1000
;
// 如果经过的时间小于帧间隔,则跳过本次更新
if
(
elapsed
<
this
.
m_frameInterval
)
{
return
;
}
// 如果时间间隔过大(大于0.1秒),说明可能是后台运行或性能问题,限制最大时间增量
// 避免因为大的时间间隔导致渲染异常
if
(
dt
>
0.1
)
{
...
...
@@ -2937,7 +2941,7 @@ export class PlayComponent implements OnInit, OnDestroy {
private
isGameStart
=
false
;
private
currentFishIndex
=
0
;
private
m_fishTimeAccumulator
=
0
;
// 累积的时间,用于鱼的生成
updateFish
(
dt
:
number
=
0
)
{
// 如果没有游戏阶段或当前阶段索引超出范围,不生成鱼
if
(
!
this
.
gameStages
||
this
.
currentStageIndex
>=
this
.
gameStages
.
length
)
{
...
...
@@ -2950,7 +2954,7 @@ export class PlayComponent implements OnInit, OnDestroy {
// 累积时间,用于鱼的生成
this
.
m_fishTimeAccumulator
+=
dt
*
1000
;
// 转换为毫秒
// 使用累积的时间来控制鱼的生成频率,从而间接控制屏幕上的鱼的数量
if
(
this
.
m_fishTimeAccumulator
>=
this
.
m_fishInterval
)
{
// 创建新的鱼
...
...
@@ -2999,7 +3003,7 @@ export class PlayComponent implements OnInit, OnDestroy {
// 鱼的基础速度是每秒60像素(1像素/帧 * 60帧/秒)
const
baseSpeed
=
60
;
// 每秒移动的像素数
const
moveDistance
=
baseSpeed
*
dt
*
fish
.
speed
;
// 向左移动鱼
fish
.
ref
.
x
-=
moveDistance
;
...
...
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