Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hy17_hds
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
hy17_hds
Commits
a7a6c756
Commit
a7a6c756
authored
Jun 20, 2023
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
录音逻辑添加
parent
87d4d7e5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
0 deletions
+81
-0
hy01_danci.ts
assets/hy01_danci/scene/hy01_danci.ts
+81
-0
No files found.
assets/hy01_danci/scene/hy01_danci.ts
View file @
a7a6c756
...
...
@@ -4,6 +4,8 @@ import pg from "./pg_hy01_danci";
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
let
win
:
any
=
window
;
let
courseware
=
win
.
courseware
;
@
ccclass
export
default
class
SceneComponent
extends
MyCocosSceneComponent
{
...
...
@@ -51,6 +53,85 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
private
letter
:
string
;
private
targetTime
:
number
;
private
recordAudio
:
string
;
//按钮触发,使用的方法
async
onTouchRecord
()
{
this
.
recordAudio
=
''
;
// let AniNode = pg.view.find(this.layout_record, 'AniNode');
// AniNode.active = true;
this
.
showTimeStart
();
cc
.
audioEngine
.
stopAllEffects
();
courseware
&&
courseware
.
startTest
(
this
.
letter
);
//开始录音
}
async
onTouchRecordEnd
()
{
// let AniNode = pg.view.find(this.layout_record, 'AniNode');
// AniNode.active = false;
this
.
showTimeEnd
();
let
testData
=
{
"
dtLastResponse
"
:
"
2021-09-17 13:36:26:109
"
,
"
refText
"
:
"
I haven't found anything out about him yet.
"
,
"
recordId
"
:
"
6144295213f0a2200000ed93
"
,
"
eof
"
:
1
,
audioUrl
:
'
http://staging-teach.cdn.ireadabc.com/43839adb578c7e01456748b8a176a0c3_l.mp3
'
,
"
result
"
:
{
"
pronunciation
"
:
25
,
"
resource_version
"
:
"
3.1.0
"
,
"
fluency
"
:
60
,
"
rhythm
"
:
90
,
"
kernel_version
"
:
"
5.2.4
"
,
"
overall
"
:
8
,
//75
"
integrity
"
:
100
,
"
duration
"
:
"
6.779
"
,
"
rear_tone
"
:
"
fall
"
,
"
speed
"
:
96
,
},
"
tokenId
"
:
"
6144295408558b08dd000001
"
,
"
applicationId
"
:
"
154838659000009e
"
}
if
(
!
courseware
)
{
return
this
.
recrodEnd
(
testData
)
}
courseware
&&
courseware
.
stopTest
((
res
)
=>
{
res
=
JSON
.
parse
(
res
);
this
.
recrodEnd
(
res
);
});
//结束录音
}
async
recrodEnd
(
data
)
{
this
.
recordAudio
=
data
.
audioUrl
;
let
score
=
data
.
result
.
overall
;
pg
.
event
.
emit
(
'
layer_record_score
'
,
score
);
}
private
startTime
:
number
;
showTimeStart
()
{
if
(
!
this
.
targetTime
)
return
;
let
nowTime
=
new
Date
().
getTime
();
this
.
startTime
=
nowTime
;
}
showTimeUpdate
()
{
if
(
!
this
.
startTime
)
return
;
let
nowTime
=
new
Date
().
getTime
();
let
subTime
=
(
nowTime
-
this
.
startTime
)
/
1000
;
let
percent
=
1
-
(
subTime
/
this
.
targetTime
);
percent
=
Math
.
max
(
percent
,
0
)
// let record_time = pg.view.find(this.layout_record, 'record_time');
// record_time.getComponent(cc.Sprite).fillRange = percent;
// if (percent == 0) {
// this.showTimeEnd();
// }
}
showTimeEnd
()
{
this
.
startTime
=
null
;
// let record_time = pg.view.find(this.layout_record, 'record_time');
// record_time.getComponent(cc.Sprite).fillRange = 0;
}
playLocalAudio
(
audioName
)
{
const
audio
=
cc
.
find
(
`Canvas/res/audio/
${
audioName
}
`
).
getComponent
(
cc
.
AudioSource
);
return
new
Promise
((
resolve
,
reject
)
=>
{
...
...
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