videomail-client 5.0.0 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/TODO.md +4 -4
- package/package.json +9 -9
- package/prototype/index.html +433 -316
- package/prototype/js/videomail-client.js +5669 -5623
- package/prototype/js/videomail-client.min.js +10 -10
- package/prototype/js/videomail-client.min.js.map +1 -1
- package/prototype/with_time_control.html +39 -0
- package/src/js/resource.js +5 -1
- package/src/js/util/browser.js +9 -7
- package/src/js/wrappers/visuals/recorder.js +14 -4
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>videomail-client examples</title>
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
<h1>BETA! Include time control to ensure video frames are in perfect order</h1>
|
|
9
|
+
<div id="videomail"></div>
|
|
10
|
+
<script src="/js/videomail-client.js"></script>
|
|
11
|
+
<script>
|
|
12
|
+
var videomailClient = new VideomailClient({
|
|
13
|
+
verbose: true,
|
|
14
|
+
enableAutoPause: false,
|
|
15
|
+
disableSubmit: true,
|
|
16
|
+
audio: {
|
|
17
|
+
enabled: true,
|
|
18
|
+
switch: true
|
|
19
|
+
},
|
|
20
|
+
image: {
|
|
21
|
+
quality: 0.5
|
|
22
|
+
},
|
|
23
|
+
video: {
|
|
24
|
+
limitSeconds: 120,
|
|
25
|
+
countdown: false,
|
|
26
|
+
width: 640,
|
|
27
|
+
timeControl: true
|
|
28
|
+
},
|
|
29
|
+
text: {
|
|
30
|
+
buttons: {
|
|
31
|
+
preview: 'Stop'
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
videomailClient.show()
|
|
37
|
+
</script>
|
|
38
|
+
</body>
|
|
39
|
+
</html>
|
package/src/js/resource.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import Constants from './constants'
|
|
2
1
|
import superagent from 'superagent'
|
|
3
2
|
|
|
3
|
+
import Constants from './constants'
|
|
4
|
+
|
|
4
5
|
const CACHE_KEY = 'alias'
|
|
5
6
|
|
|
6
7
|
export default function (options) {
|
|
@@ -39,9 +40,12 @@ export default function (options) {
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
function fetch(alias, cb) {
|
|
43
|
+
const timezoneId = Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
44
|
+
|
|
42
45
|
superagent
|
|
43
46
|
.get('/videomail/' + alias + '/snapshot')
|
|
44
47
|
.set('Accept', 'application/json')
|
|
48
|
+
.set('Accept-Timezone', timezoneId)
|
|
45
49
|
.set(Constants.SITE_NAME_LABEL, options.siteName)
|
|
46
50
|
.timeout(options.timeouts.connection)
|
|
47
51
|
.end(function (err, res) {
|
package/src/js/util/browser.js
CHANGED
|
@@ -3,6 +3,8 @@ import UAParser from 'ua-parser-js'
|
|
|
3
3
|
|
|
4
4
|
import VideomailError from './videomailError'
|
|
5
5
|
|
|
6
|
+
const FALLBACK_VIDEO_TYPE = 'webm'
|
|
7
|
+
|
|
6
8
|
const Browser = function (options) {
|
|
7
9
|
options = options || {}
|
|
8
10
|
|
|
@@ -257,12 +259,7 @@ const Browser = function (options) {
|
|
|
257
259
|
}
|
|
258
260
|
|
|
259
261
|
this.getVideoType = function (video) {
|
|
260
|
-
if (!video) {
|
|
261
|
-
// no type without video
|
|
262
|
-
return
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
if (!videoType) {
|
|
262
|
+
if (!videoType && video) {
|
|
266
263
|
if (canPlayType(video, 'webm')) {
|
|
267
264
|
videoType = 'webm'
|
|
268
265
|
} else if (canPlayType(video, 'mp4')) {
|
|
@@ -270,9 +267,14 @@ const Browser = function (options) {
|
|
|
270
267
|
}
|
|
271
268
|
}
|
|
272
269
|
|
|
270
|
+
if (videoType !== 'webm' && videoType !== 'mp4') {
|
|
271
|
+
// we only support these two. anything else defaults to the fallback.
|
|
272
|
+
videoType = FALLBACK_VIDEO_TYPE
|
|
273
|
+
}
|
|
274
|
+
|
|
273
275
|
if (!videoType || videoType === '') {
|
|
274
276
|
// just as a fallback
|
|
275
|
-
videoType =
|
|
277
|
+
videoType = FALLBACK_VIDEO_TYPE
|
|
276
278
|
}
|
|
277
279
|
|
|
278
280
|
return videoType
|
|
@@ -88,6 +88,8 @@ const Recorder = function (visuals, replay, defaultOptions = {}) {
|
|
|
88
88
|
let recordingBufferLength
|
|
89
89
|
let recordingBuffer
|
|
90
90
|
|
|
91
|
+
const timeControlEnabled = Boolean(options.video.timeControl)
|
|
92
|
+
|
|
91
93
|
function writeStream(buffer, opts) {
|
|
92
94
|
if (stream) {
|
|
93
95
|
if (stream.destroyed) {
|
|
@@ -991,6 +993,7 @@ const Recorder = function (visuals, replay, defaultOptions = {}) {
|
|
|
991
993
|
if (!self.isPaused() && stream && ctx) {
|
|
992
994
|
if (framesCount === 0) {
|
|
993
995
|
self.emit(Events.SENDING_FIRST_FRAME)
|
|
996
|
+
debug('Recorder: time control is', timeControlEnabled.toString())
|
|
994
997
|
}
|
|
995
998
|
|
|
996
999
|
framesCount++
|
|
@@ -1006,10 +1009,17 @@ const Recorder = function (visuals, replay, defaultOptions = {}) {
|
|
|
1006
1009
|
|
|
1007
1010
|
bytesSum += recordingBufferLength
|
|
1008
1011
|
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
)
|
|
1012
|
-
|
|
1012
|
+
let frameBuffer
|
|
1013
|
+
|
|
1014
|
+
if (timeControlEnabled) {
|
|
1015
|
+
const timeControlBuffer = Buffer.from(
|
|
1016
|
+
stringify({ frameNumber: framesCount, milliseconds: Date.now() })
|
|
1017
|
+
)
|
|
1018
|
+
|
|
1019
|
+
frameBuffer = Buffer.concat([recordingBuffer, timeControlBuffer])
|
|
1020
|
+
} else {
|
|
1021
|
+
frameBuffer = recordingBuffer
|
|
1022
|
+
}
|
|
1013
1023
|
|
|
1014
1024
|
writeStream(frameBuffer, {
|
|
1015
1025
|
frameNumber: framesCount,
|