-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmobile-video.html
103 lines (86 loc) · 3.62 KB
/
mobile-video.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>qVideo - Audio Video capture in Qualtrics</title>
<meta name="description" content="Audio Video capture in Qualtrics">
<meta name="author" content="Gabe Mansur">
<script src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css"
integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4"
crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="css/qVideoMobileStyle.css"></link>
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<body>
<div class="container">
<div class="row">
<div class="col-md-12 video-container" style="width:90%; margin: 0 auto;">
<div class="alert alert-success" id="msg" role="alert"></div>
<div class="alert alert-danger" id="err" role="alert"></div>
<h4 class="text-center text-primary" id="review-msg">
If you are happy with your video, click "Upload".<br>Otherwise, click "Open Camera" to record another one.
</h4>
<!--
<label class="btn btn-danger btn-file">
Record <input type="file" accept="video/*" capture="user" id="recorder" style="display: none;">
</label>
-->
<a id="download">Download
<button id="stop">Stop
<video id="player" controls></video>
</div>
</div>
</div>
<script>
const uploadUrl = 'upload.php';
const params={};location.search.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(s,k,v){params[k]=v})
const u_id = params.id; // This will be pulled from Qualtrics (or possibly some other source)
const review = params.review;
let shouldStop = false;
let stopped = false;
const downloadLink = document.getElementById('download');
const stopButton = document.getElementById('stop');
stopButton.addEventListener('click', function() {
shouldStop = true;
});
const recorder = document.getElementById('recorder');
const player = document.getElementById('player');
const allowReview = (review == 'true') ? true : false;
var handleSuccess = function(stream) {
const options = {mimeType: 'video/webm'};
const recordedChunks = [];
const mediaRecorder = new MediaRecorder(stream, options);
mediaRecorder.addEventListener('dataavailable', function(e) {
if (e.data.size > 0) {
recordedChunks.push(e.data);
}
if(shouldStop === true && stopped === false) {
mediaRecorder.stop();
stopped = true;
}
});
mediaRecorder.addEventListener('stop', function() {
downloadLink.href = URL.createObjectURL(new Blob(recordedChunks));
downloadLink.download = 'acetest.webm';
});
mediaRecorder.start();
};
navigator.mediaDevices.getUserMedia({ audio: true, video: true })
.then(handleSuccess);
</script>
<!-- <script src="js/qVideo.js"></script> -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"
integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"
integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm"
crossorigin="anonymous"></script>
</body>
</html>