Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fireballoon
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
fireballoon
Commits
4eb9a32d
Commit
4eb9a32d
authored
3 years ago
by
yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
410914b8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
11 deletions
+52
-11
audio-recorder.component.ts
...src/app/common/audio-recorder/audio-recorder.component.ts
+52
-11
No files found.
form/src/app/common/audio-recorder/audio-recorder.component.ts
View file @
4eb9a32d
import
{
Component
,
EventEmitter
,
Input
,
OnDestroy
,
OnInit
,
Output
,
NgZone
,
OnChanges
}
from
'
@angular/core
'
;
import
{
Component
,
EventEmitter
,
Input
,
OnDestroy
,
OnInit
,
Output
,
NgZone
,
OnChanges
}
from
'
@angular/core
'
;
import
{
NzMessageService
,
NzNotificationService
,
UploadFile
}
from
'
ng-zorro-antd
'
;
import
{
NzMessageService
,
NzNotificationService
,
UploadFile
}
from
'
ng-zorro-antd
'
;
import
{
HttpClient
,
HttpEvent
,
HttpEventType
,
HttpRequest
}
from
'
@angular/common/http
'
;
import
{
HttpClient
,
HttpEvent
,
HttpEventType
,
HttpRequest
}
from
'
@angular/common/http
'
;
import
{
environment
}
from
'
../../../environments/environment
'
;
import
{
environment
}
from
'
../../../environments/environment
'
;
declare
var
Recorder
;
declare
var
Recorder
;
...
@@ -35,8 +35,14 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -35,8 +35,14 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
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
();
}
}
...
@@ -54,9 +60,9 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -54,9 +60,9 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
audioBlob
:
any
;
audioBlob
:
any
;
constructor
(
private
nzMessageService
:
NzMessageService
)
{
constructor
(
private
nzMessageService
:
NzMessageService
)
{
this
.
uploadUrl
=
(
<
any
>
window
).
courseware
.
uploadUrl
();
this
.
uploadUrl
=
(
<
any
>
window
).
courseware
.
uploadUrl
();
this
.
uploadData
=
(
<
any
>
window
).
courseware
.
uploadData
();
this
.
uploadData
=
(
<
any
>
window
).
courseware
.
uploadData
();
window
[
'
air
'
].
getUploadCallback
=
(
url
,
data
)
=>
{
window
[
'
air
'
].
getUploadCallback
=
(
url
,
data
)
=>
{
this
.
uploadUrl
=
url
;
this
.
uploadUrl
=
url
;
...
@@ -64,6 +70,41 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -64,6 +70,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
;
...
...
This diff is collapsed.
Click to expand it.
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