Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-060
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2021-060
2021-060
Commits
f6be1a29
Commit
f6be1a29
authored
Sep 21, 2021
by
Dhananjaya Jayashanka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
done changers
parent
7a28c551
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
149 deletions
+0
-149
UI/main.css
UI/main.css
+0
-31
UI/script.js
UI/script.js
+0
-118
No files found.
UI/main.css
deleted
100644 → 0
View file @
7a28c551
button
{
margin
:
0
3px
10px
0
;
padding-left
:
2px
;
padding-right
:
2px
;
width
:
300px
;
}
button
:last-of-type
{
margin
:
0
;
}
p
.borderBelow
{
margin
:
0
0
20px
0
;
padding
:
0
0
20px
0
;
}
video
{
vertical-align
:
top
;
--width
:
25vw
;
width
:
var
(
--width
);
height
:
calc
(
var
(
--width
)
*
0.5625
);
}
video
:last-of-type
{
margin
:
0
0
20px
0
;
}
video
#gumVideo
{
margin
:
0
20px
20px
0
;
}
UI/script.js
deleted
100644 → 0
View file @
7a28c551
'
use strict
'
;
/* globals MediaRecorder */
let
mediaRecorder
;
let
recordedBlobs
;
const
errorMsgElement
=
document
.
querySelector
(
'
span#errorMsg
'
);
const
recordedVideo
=
document
.
querySelector
(
'
video#recorded
'
);
const
recordButton
=
document
.
querySelector
(
'
button#record
'
);
const
playButton
=
document
.
querySelector
(
'
button#play
'
);
const
downloadButton
=
document
.
querySelector
(
'
button#download
'
);
recordButton
.
addEventListener
(
'
click
'
,
()
=>
{
if
(
recordButton
.
textContent
===
'
Record
'
)
{
startRecording
();
}
else
{
stopRecording
();
recordButton
.
textContent
=
'
Record
'
;
playButton
.
disabled
=
false
;
downloadButton
.
disabled
=
false
;
}
});
playButton
.
addEventListener
(
'
click
'
,
()
=>
{
const
superBuffer
=
new
Blob
(
recordedBlobs
,
{
type
:
'
video/webm
'
});
recordedVideo
.
src
=
null
;
recordedVideo
.
srcObject
=
null
;
recordedVideo
.
src
=
window
.
URL
.
createObjectURL
(
superBuffer
);
recordedVideo
.
controls
=
true
;
recordedVideo
.
play
();
});
downloadButton
.
addEventListener
(
'
click
'
,
()
=>
{
const
blob
=
new
Blob
(
recordedBlobs
,
{
type
:
'
video/mp4
'
});
const
url
=
window
.
URL
.
createObjectURL
(
blob
);
const
a
=
document
.
createElement
(
'
a
'
);
a
.
style
.
display
=
'
none
'
;
a
.
href
=
url
;
a
.
download
=
'
test.mp4
'
;
document
.
body
.
appendChild
(
a
);
a
.
click
();
setTimeout
(()
=>
{
document
.
body
.
removeChild
(
a
);
window
.
URL
.
revokeObjectURL
(
url
);
},
100
);
});
function
handleDataAvailable
(
event
)
{
console
.
log
(
'
handleDataAvailable
'
,
event
);
if
(
event
.
data
&&
event
.
data
.
size
>
0
)
{
recordedBlobs
.
push
(
event
.
data
);
}
}
function
startRecording
()
{
recordedBlobs
=
[];
let
options
=
{
mimeType
:
'
video/webm;codecs=vp9,opus
'
};
try
{
mediaRecorder
=
new
MediaRecorder
(
window
.
stream
,
options
);
}
catch
(
e
)
{
console
.
error
(
'
Exception while creating MediaRecorder:
'
,
e
);
errorMsgElement
.
innerHTML
=
`Exception while creating MediaRecorder:
${
JSON
.
stringify
(
e
)}
`
;
return
;
}
console
.
log
(
'
Created MediaRecorder
'
,
mediaRecorder
,
'
with options
'
,
options
);
recordButton
.
textContent
=
'
Stop Recording
'
;
playButton
.
disabled
=
true
;
downloadButton
.
disabled
=
true
;
mediaRecorder
.
onstop
=
(
event
)
=>
{
console
.
log
(
'
Recorder stopped:
'
,
event
);
console
.
log
(
'
Recorded Blobs:
'
,
recordedBlobs
);
};
mediaRecorder
.
ondataavailable
=
handleDataAvailable
;
mediaRecorder
.
start
();
console
.
log
(
'
MediaRecorder started
'
,
mediaRecorder
);
}
function
stopRecording
()
{
mediaRecorder
.
stop
();
}
function
handleSuccess
(
stream
)
{
recordButton
.
disabled
=
false
;
console
.
log
(
'
getUserMedia() got stream:
'
,
stream
);
window
.
stream
=
stream
;
const
gumVideo
=
document
.
querySelector
(
'
video#gum
'
);
gumVideo
.
srcObject
=
stream
;
}
async
function
init
(
constraints
)
{
try
{
const
stream
=
await
navigator
.
mediaDevices
.
getUserMedia
(
constraints
);
handleSuccess
(
stream
);
}
catch
(
e
)
{
console
.
error
(
'
navigator.getUserMedia error:
'
,
e
);
errorMsgElement
.
innerHTML
=
`navigator.getUserMedia error:
${
e
.
toString
()}
`
;
}
}
document
.
querySelector
(
'
button#start
'
).
addEventListener
(
'
click
'
,
async
()
=>
{
const
hasEchoCancellation
=
document
.
querySelector
(
'
#echoCancellation
'
).
checked
;
const
constraints
=
{
audio
:
{
echoCancellation
:
{
exact
:
hasEchoCancellation
}
},
video
:
{
width
:
1280
,
height
:
720
}
};
console
.
log
(
'
Using media constraints:
'
,
constraints
);
await
init
(
constraints
);
});
\ No newline at end of file
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