Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sn19_read
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
sn19_read
Commits
2e380fa0
Commit
2e380fa0
authored
Jun 08, 2022
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: cocos添加上报成绩方法;angular添加音视频转码处理
parent
cd81da97
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
107 additions
and
35 deletions
+107
-35
util.ts
assets/cocos_generator/script/util.ts
+3
-5
audio-recorder.component.html
...c/app/common/audio-recorder/audio-recorder.component.html
+2
-4
audio-recorder.component.scss
...c/app/common/audio-recorder/audio-recorder.component.scss
+12
-3
audio-recorder.component.ts
...src/app/common/audio-recorder/audio-recorder.component.ts
+51
-2
upload-video.component.ts
...lar/src/app/common/upload-video/upload-video.component.ts
+39
-21
No files found.
assets/cocos_generator/script/util.ts
View file @
2e380fa0
...
@@ -411,15 +411,13 @@ export function showTrebleFirework(baseNode, rabbonList) {
...
@@ -411,15 +411,13 @@ export function showTrebleFirework(baseNode, rabbonList) {
showFireworks
(
right
);
showFireworks
(
right
);
}
}
export
function
onHomeworkFinish
()
{
export
function
onHomeworkFinish
(
data
=
""
,
callback
=
()
=>
{}
)
{
const
middleLayer
=
cc
.
find
(
'
middleLayer
'
);
const
middleLayer
=
cc
.
find
(
'
middleLayer
'
);
if
(
middleLayer
)
{
if
(
middleLayer
)
{
const
middleLayerComponent
=
middleLayer
.
getComponent
(
'
middleLayer
'
);
const
middleLayerComponent
=
middleLayer
.
getComponent
(
'
middleLayer
'
);
if
(
middleLayerComponent
.
role
==
'
student
'
)
{
middleLayerComponent
.
onHomeworkFinish
(
callback
,
data
);
middleLayerComponent
.
onHomeworkFinish
(()
=>
{
});
}
}
else
{
}
else
{
console
.
log
(
'
onHomeworkFinish
'
);
console
.
log
(
'
onHomeworkFinish
'
,
JSON
.
stringify
(
data
)
);
}
}
}
}
...
...
form_angular/src/app/common/audio-recorder/audio-recorder.component.html
View file @
2e380fa0
...
@@ -45,10 +45,6 @@
...
@@ -45,10 +45,6 @@
<fa-icon
icon=
"cog"
></fa-icon>
<fa-icon
icon=
"cog"
></fa-icon>
</div>
</div>
</ng-template>
</ng-template>
</div>
</div>
<div
class=
"p-progress ml-2"
(
click
)="
onBtnPlay
()"
*
ngIf=
"audioUrl || audioBlob"
>
<div
class=
"p-progress ml-2"
(
click
)="
onBtnPlay
()"
*
ngIf=
"audioUrl || audioBlob"
>
...
@@ -58,4 +54,6 @@
...
@@ -58,4 +54,6 @@
<fa-icon
[
icon
]="
playIcon
"
></fa-icon>
<fa-icon
[
icon
]="
playIcon
"
></fa-icon>
</div>
</div>
</div>
</div>
<div
class=
"audio-name"
>
{{_audioName}}
</div>
</div>
</div>
form_angular/src/app/common/audio-recorder/audio-recorder.component.scss
View file @
2e380fa0
...
@@ -90,17 +90,26 @@
...
@@ -90,17 +90,26 @@
}
}
.p-progress
{
.p-progress
{
margin-top
:
2
px
;
margin-top
:
3
.5
px
;
position
:
relative
;
position
:
relative
;
background-color
:
#27b43f
;
border-radius
:
15px
;
line-height
:
26px
;
line-height
:
26px
;
.p-btn-play
{
.p-btn-play
{
position
:
absolute
;
position
:
absolute
;
left
:
1
0
px
;
left
:
1
1
px
;
top
:
3px
;
top
:
3px
;
color
:
#
555
;
color
:
#
ffffff
;
}
}
}
}
.audio-name
{
margin-top
:
3
.5px
;
position
:
relative
;
margin-left
:
7px
;;
line-height
:
26px
;
}
:host
::ng-deep
nz-upload
{
:host
::ng-deep
nz-upload
{
line-height
:
33px
;
line-height
:
33px
;
}
}
...
...
form_angular/src/app/common/audio-recorder/audio-recorder.component.ts
View file @
2e380fa0
...
@@ -31,12 +31,21 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -31,12 +31,21 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
@
Input
()
@
Input
()
audioItem
:
any
=
null
;
audioItem
:
any
=
null
;
@
Input
()
_audioName
:
any
=
null
;
@
Input
()
@
Input
()
set
audioUrl
(
url
)
{
set
audioUrl
(
url
)
{
this
.
_audioUrl
=
url
;
this
.
_audioUrl
=
url
;
if
(
url
)
{
if
(
url
)
{
this
.
httpHeadCall
(
this
.
_audioUrl
,
flag
=>
{
if
(
flag
)
{
this
.
audio
.
src
=
this
.
_audioUrl
;
this
.
audio
.
src
=
this
.
_audioUrl
;
}
else
{
this
.
audio
.
src
=
this
.
_audioUrl
.
replace
(
"
_l.
"
,
"
.
"
);
}
this
.
audio
.
load
();
this
.
audio
.
load
();
});
}
}
this
.
init
();
this
.
init
();
}
}
...
@@ -48,6 +57,7 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -48,6 +57,7 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
@
Output
()
audioUploaded
=
new
EventEmitter
();
@
Output
()
audioUploaded
=
new
EventEmitter
();
@
Output
()
audioUploadFailure
=
new
EventEmitter
();
@
Output
()
audioUploadFailure
=
new
EventEmitter
();
@
Output
()
audioRemoved
=
new
EventEmitter
();
@
Output
()
audioRemoved
=
new
EventEmitter
();
@
Output
()
audioName
=
new
EventEmitter
();
percent
=
0
;
percent
=
0
;
progress
=
0
;
progress
=
0
;
recorder
:
any
;
recorder
:
any
;
...
@@ -64,6 +74,41 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -64,6 +74,41 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
};
};
}
}
httpHeadCall
(
requsetUrl
:
string
,
callback
)
{
let
xhr
=
new
XMLHttpRequest
();
console
.
log
(
"
Status: Send Post Request to
"
+
requsetUrl
);
try
{
xhr
.
onreadystatechange
=
()
=>
{
try
{
console
.
log
(
'
xhr.readyState:
'
,
xhr
.
readyState
);
if
(
xhr
.
readyState
==
4
)
{
if
((
xhr
.
status
>=
200
&&
xhr
.
status
<
400
))
{
callback
(
true
);
}
else
{
callback
(
false
);
}
}
}
catch
(
e
)
{
console
.
log
(
e
)
}
};
xhr
.
open
(
"
HEAD
"
,
requsetUrl
,
true
);
xhr
.
send
();
xhr
.
timeout
=
15000
;
xhr
.
onerror
=
(
e
)
=>
{
console
.
log
(
"
汪汪汪 posterror
"
,
e
);
callback
(
false
);
};
xhr
.
ontimeout
=
(
e
)
=>
{
console
.
log
(
"
汪汪汪 ontimeout
"
,
e
);
callback
(
false
);
};
}
catch
(
e
)
{
console
.
log
(
"
Send Get Request error:
"
,
e
)
}
}
init
()
{
init
()
{
this
.
playIcon
=
'
play
'
;
this
.
playIcon
=
'
play
'
;
this
.
isPlaying
=
false
;
this
.
isPlaying
=
false
;
...
@@ -168,8 +213,12 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -168,8 +213,12 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
break
;
break
;
case
'
success
'
:
case
'
success
'
:
this
.
isUploading
=
false
;
this
.
isUploading
=
false
;
let
url
=
info
.
file
.
response
.
url
;
url
=
url
.
substring
(
0
,
url
.
lastIndexOf
(
"
.
"
))
+
"
_l.mp3
"
;
info
.
file
.
response
.
url
=
url
;
this
.
uploadSuccess
(
info
.
file
.
response
);
this
.
uploadSuccess
(
info
.
file
.
response
);
this
.
audioUploaded
.
emit
(
info
.
file
.
response
);
this
.
audioUploaded
.
emit
(
info
.
file
.
response
);
this
.
audioName
.
emit
(
info
.
file
.
name
);
break
;
break
;
case
'
progress
'
:
case
'
progress
'
:
this
.
progress
=
parseInt
(
info
.
event
.
percent
,
10
);
this
.
progress
=
parseInt
(
info
.
event
.
percent
,
10
);
...
...
form_angular/src/app/common/upload-video/upload-video.component.ts
View file @
2e380fa0
...
@@ -80,43 +80,62 @@ export class UploadVideoComponent implements OnChanges, OnDestroy {
...
@@ -80,43 +80,62 @@ export class UploadVideoComponent implements OnChanges, OnDestroy {
URL
.
revokeObjectURL
(
this
.
videoUrl
);
URL
.
revokeObjectURL
(
this
.
videoUrl
);
}
}
safeVideoUrl
(
url
)
{
httpHeadCall
(
requsetUrl
:
string
,
callback
)
{
console
.
log
(
url
);
let
xhr
=
new
XMLHttpRequest
();
return
this
.
sanitization
.
bypassSecurityTrustResourceUrl
(
url
);
// `${url}`;
console
.
log
(
"
Status: Send Post Request to
"
+
requsetUrl
);
try
{
xhr
.
onreadystatechange
=
()
=>
{
try
{
console
.
log
(
'
xhr.readyState:
'
,
xhr
.
readyState
);
if
(
xhr
.
readyState
==
4
)
{
if
((
xhr
.
status
>=
200
&&
xhr
.
status
<
400
))
{
callback
(
true
);
}
else
{
callback
(
false
);
}
}
}
videoLoadedMetaData
()
{
}
catch
(
e
)
{
console
.
log
(
e
)
}
};
xhr
.
open
(
"
HEAD
"
,
requsetUrl
,
true
);
xhr
.
send
();
xhr
.
timeout
=
15000
;
xhr
.
onerror
=
(
e
)
=>
{
callback
(
false
);
};
xhr
.
ontimeout
=
(
e
)
=>
{
callback
(
false
);
};
}
catch
(
e
)
{
console
.
log
(
"
Send Get Request error:
"
,
e
)
}
}
}
safeVideoUrl
(
url
)
{
const
_url
=
url
.
replace
(
"
_l.
"
,
"
.
"
);
return
this
.
sanitization
.
bypassSecurityTrustResourceUrl
(
_url
);
// `${url}`;
}
videoLoadedMetaData
()
{
handleChange
(
info
:
UploadChangeParam
/* { type: string, file: UploadFile, event: any }*/
):
void
{
}
console
.
log
(
'
info:
'
,
info
);
handleChange
(
info
:
UploadChangeParam
):
void
{
switch
(
info
.
type
)
{
switch
(
info
.
type
)
{
case
'
start
'
:
case
'
start
'
:
// this.beforeUpload(info.file);
if
(
!
this
.
checkSelectFile
(
info
.
file
))
{
if
(
!
this
.
checkSelectFile
(
info
.
file
))
{
return
;
return
;
}
}
this
.
uploading
=
true
;
this
.
uploading
=
true
;
this
.
progress
=
0
;
this
.
progress
=
0
;
break
;
break
;
case
'
success
'
:
case
'
success
'
:
let
url
=
info
.
file
.
response
.
url
;
url
=
url
.
substring
(
0
,
url
.
lastIndexOf
(
"
.
"
))
+
"
_l.mp4
"
;
info
.
file
.
response
.
url
=
url
;
this
.
uploadSuccess
(
info
.
file
);
this
.
uploadSuccess
(
info
.
file
);
// this.beforeUpload(info.file);
// this.uploadSuccess(info.file);
break
;
break
;
case
'
progress
'
:
case
'
progress
'
:
this
.
progress
=
info
.
event
.
percent
;
this
.
progress
=
info
.
event
.
percent
;
...
@@ -125,7 +144,6 @@ export class UploadVideoComponent implements OnChanges, OnDestroy {
...
@@ -125,7 +144,6 @@ export class UploadVideoComponent implements OnChanges, OnDestroy {
}
}
}
}
checkSelectFile
(
file
)
{
checkSelectFile
(
file
)
{
if
(
!
file
.
lastModified
)
{
if
(
!
file
.
lastModified
)
{
return
false
;
return
false
;
...
...
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