Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
ls_gramophone
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
ls_gramophone
Commits
c5834d39
Commit
c5834d39
authored
Jun 08, 2022
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 上传音频问题
parent
d4a11193
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
2 deletions
+43
-2
audio-recorder.component.ts
...src/app/common/audio-recorder/audio-recorder.component.ts
+43
-2
No files found.
form/src/app/common/audio-recorder/audio-recorder.component.ts
View file @
c5834d39
...
@@ -38,8 +38,14 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -38,8 +38,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
();
}
}
...
@@ -68,6 +74,41 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -68,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
;
...
...
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