videomail-client 8.3.1 → 8.3.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.
Files changed (38) hide show
  1. package/package.json +1 -1
  2. package/prototype/js/videomail-client.js +12 -14
  3. package/prototype/js/videomail-client.min.js +1 -1
  4. package/prototype/js/videomail-client.min.js.map +1 -1
  5. package/src/js/client.js +0 -210
  6. package/src/js/constants.js +0 -11
  7. package/src/js/events.js +0 -46
  8. package/src/js/index.js +0 -15
  9. package/src/js/options.js +0 -180
  10. package/src/js/resource.js +0 -206
  11. package/src/js/util/audioRecorder.js +0 -152
  12. package/src/js/util/browser.js +0 -319
  13. package/src/js/util/collectLogger.js +0 -72
  14. package/src/js/util/eventEmitter.js +0 -72
  15. package/src/js/util/humanize.js +0 -16
  16. package/src/js/util/mediaEvents.js +0 -148
  17. package/src/js/util/pretty.js +0 -70
  18. package/src/js/util/standardize.js +0 -71
  19. package/src/js/util/videomailError.js +0 -431
  20. package/src/js/wrappers/buttons.js +0 -670
  21. package/src/js/wrappers/container.js +0 -797
  22. package/src/js/wrappers/dimension.js +0 -149
  23. package/src/js/wrappers/form.js +0 -319
  24. package/src/js/wrappers/optionsWrapper.js +0 -81
  25. package/src/js/wrappers/visuals/inside/recorder/countdown.js +0 -83
  26. package/src/js/wrappers/visuals/inside/recorder/facingMode.js +0 -53
  27. package/src/js/wrappers/visuals/inside/recorder/pausedNote.js +0 -59
  28. package/src/js/wrappers/visuals/inside/recorder/recordNote.js +0 -42
  29. package/src/js/wrappers/visuals/inside/recorder/recordTimer.js +0 -149
  30. package/src/js/wrappers/visuals/inside/recorderInsides.js +0 -144
  31. package/src/js/wrappers/visuals/notifier.js +0 -341
  32. package/src/js/wrappers/visuals/recorder.js +0 -1492
  33. package/src/js/wrappers/visuals/replay.js +0 -355
  34. package/src/js/wrappers/visuals/userMedia.js +0 -541
  35. package/src/js/wrappers/visuals.js +0 -410
  36. package/src/styles/css/main.min.css.js +0 -1
  37. package/src/styles/styl/keyframes/blink.styl +0 -16
  38. package/src/styles/styl/main.styl +0 -126
@@ -1,355 +0,0 @@
1
- import addEventListenerWithOptions from "add-eventlistener-with-options";
2
- import hidden from "hidden";
3
- import h from "hyperscript";
4
- import enableInlineVideo from "iphone-inline-video";
5
- import inherits from "inherits";
6
-
7
- import Events from "../../events";
8
- import Browser from "../../util/browser";
9
- import EventEmitter from "../../util/eventEmitter";
10
- import VideomailError from "../../util/videomailError";
11
-
12
- const Replay = function (parentElement, options) {
13
- EventEmitter.call(this, options, "Replay");
14
-
15
- const self = this;
16
- const browser = new Browser(options);
17
- const { debug } = options;
18
-
19
- let built;
20
- let replayElement;
21
- let videomail;
22
-
23
- function buildElement() {
24
- debug("Replay: buildElement()");
25
-
26
- replayElement = h(`video.${options.selectors.replayClass}`);
27
-
28
- if (!replayElement.setAttribute) {
29
- throw VideomailError.create("Please upgrade browser", options);
30
- }
31
-
32
- parentElement.appendChild(replayElement);
33
- }
34
-
35
- function isStandalone() {
36
- return parentElement.constructor.name === "HTMLDivElement";
37
- }
38
-
39
- function copyAttributes(newVideomail) {
40
- let attributeContainer;
41
-
42
- Object.keys(newVideomail).forEach(function (attribute) {
43
- attributeContainer = parentElement.querySelector(`.${attribute}`);
44
-
45
- if (attributeContainer) {
46
- attributeContainer.innerHTML = newVideomail[attribute];
47
- }
48
- });
49
- }
50
-
51
- function correctDimensions(options) {
52
- let height, width;
53
-
54
- if (videomail && videomail.playerWidth) {
55
- width = videomail.playerWidth;
56
- } else if (parentElement.calculateWidth) {
57
- width = parentElement.calculateWidth(options);
58
- }
59
-
60
- if (videomail && videomail.playerHeight) {
61
- height = videomail.playerHeight;
62
- } else if (parentElement.calculateHeight) {
63
- height = parentElement.calculateHeight(options);
64
- }
65
-
66
- if (width > 0) {
67
- replayElement.style.width = `${width}px`;
68
- } else {
69
- replayElement.style.width = "auto";
70
- }
71
-
72
- if (height > 0) {
73
- replayElement.style.height = `${height}px`;
74
- } else {
75
- replayElement.style.height = "auto";
76
- }
77
- }
78
-
79
- this.setVideomail = function (newVideomail) {
80
- videomail = newVideomail;
81
-
82
- if (videomail) {
83
- if (videomail.mp4) {
84
- this.setMp4Source(videomail.mp4);
85
- }
86
-
87
- if (videomail.webm) {
88
- this.setWebMSource(videomail.webm);
89
- }
90
-
91
- if (videomail.poster) {
92
- replayElement.setAttribute("poster", videomail.poster);
93
- }
94
-
95
- copyAttributes(videomail);
96
- }
97
-
98
- const hasAudio =
99
- videomail && videomail.recordingStats && videomail.recordingStats.sampleRate > 0;
100
-
101
- this.show(videomail && videomail.width, videomail && videomail.height, hasAudio);
102
- };
103
-
104
- this.show = function (recorderWidth, recorderHeight, hasAudio) {
105
- if (videomail) {
106
- correctDimensions({
107
- responsive: true,
108
- // beware that recorderWidth and recorderHeight can be null sometimes
109
- videoWidth: recorderWidth || replayElement.videoWidth,
110
- videoHeight: recorderHeight || replayElement.videoHeight,
111
- });
112
- }
113
-
114
- hidden(replayElement, false);
115
-
116
- // parent element can be any object, be careful!
117
- if (parentElement) {
118
- if (parentElement.style) {
119
- hidden(parentElement, false);
120
- } else if (parentElement.show) {
121
- parentElement.show();
122
- }
123
- }
124
-
125
- if (hasAudio) {
126
- /*
127
- * https://github.com/binarykitchen/videomail-client/issues/115
128
- * do not set mute to false as this will mess up. just do not mention this attribute at all
129
- */
130
- replayElement.setAttribute("volume", 1);
131
- } else if (!options.isAudioEnabled()) {
132
- replayElement.setAttribute("muted", true);
133
- }
134
-
135
- /*
136
- * this must be called after setting the sources and when becoming visible
137
- * see https://github.com/bfred-it/iphone-inline-video/issues/16
138
- */
139
- enableInlineVideo &&
140
- enableInlineVideo(replayElement, {
141
- iPad: true,
142
- });
143
-
144
- // this forces to actually fetch the videos from the server
145
- replayElement.load();
146
-
147
- if (!videomail) {
148
- self.emit(Events.PREVIEW_SHOWN);
149
- } else {
150
- self.emit(Events.REPLAY_SHOWN);
151
- }
152
- };
153
-
154
- this.build = function () {
155
- debug("Replay: build()");
156
-
157
- replayElement = parentElement.querySelector(`video.${options.selectors.replayClass}`);
158
-
159
- if (!replayElement) {
160
- buildElement();
161
- }
162
-
163
- this.hide();
164
-
165
- replayElement.setAttribute("autoplay", true);
166
- replayElement.setAttribute("autostart", true);
167
- replayElement.setAttribute("autobuffer", true);
168
- replayElement.setAttribute("playsinline", true);
169
- replayElement.setAttribute("webkit-playsinline", "webkit-playsinline");
170
- replayElement.setAttribute("controls", "controls");
171
- replayElement.setAttribute("preload", "auto");
172
-
173
- if (!built) {
174
- if (!isStandalone()) {
175
- this.on(Events.PREVIEW, function (key, recorderWidth, recorderHeight) {
176
- self.show(recorderWidth, recorderHeight);
177
- });
178
- }
179
-
180
- /*
181
- * makes use of passive option automatically for better performance
182
- * https://www.npmjs.com/package/add-eventlistener-with-options
183
- */
184
- addEventListenerWithOptions(replayElement, "touchstart", function (e) {
185
- try {
186
- e && e.preventDefault();
187
- } catch (exc) {
188
- /*
189
- * ignore errors like
190
- * Unable to preventDefault inside passive event listener invocation.
191
- */
192
- }
193
-
194
- if (this.paused) {
195
- play();
196
- } else {
197
- pause();
198
- }
199
- });
200
-
201
- replayElement.onclick = function (e) {
202
- e && e.preventDefault();
203
-
204
- if (this.paused) {
205
- play();
206
- } else {
207
- pause();
208
- }
209
- };
210
- }
211
-
212
- built = true;
213
-
214
- debug("Replay: built.");
215
- };
216
-
217
- this.unload = function () {
218
- built = false;
219
- };
220
-
221
- this.getVideoSource = function (type) {
222
- const sources = replayElement.getElementsByTagName("source");
223
- const l = sources && sources.length;
224
- const videoType = `video/${type}`;
225
-
226
- let source;
227
-
228
- if (l) {
229
- let i;
230
-
231
- for (i = 0; i < l && !source; i++) {
232
- if (sources[i].getAttribute("type") === videoType) {
233
- source = sources[i];
234
- }
235
- }
236
- }
237
-
238
- return source;
239
- };
240
-
241
- function setVideoSource(type, src, bustCache) {
242
- let source = self.getVideoSource(type);
243
-
244
- if (src && bustCache) {
245
- src += `?${Date.now()}`;
246
- }
247
-
248
- if (!source) {
249
- if (src) {
250
- const { fps } = options.video;
251
-
252
- // Ensure it's greater than the frame duration itself
253
- const t = 2 * (1 / fps);
254
-
255
- source = h("source", {
256
- /*
257
- * Ensures HTML video thumbnail turns up on iOS, see
258
- * https://muffinman.io/blog/hack-for-ios-safari-to-display-html-video-thumbnail/
259
- */
260
- src: `${src}#t=${t}`,
261
- type: `video/${type}`,
262
- });
263
-
264
- replayElement.appendChild(source);
265
- }
266
- } else if (src) {
267
- source.setAttribute("src", src);
268
- } else {
269
- replayElement.removeChild(source);
270
- }
271
- }
272
-
273
- this.setMp4Source = function (src, bustCache) {
274
- setVideoSource("mp4", src, bustCache);
275
- };
276
-
277
- this.setWebMSource = function (src, bustCache) {
278
- setVideoSource("webm", src, bustCache);
279
- };
280
-
281
- this.getVideoType = function () {
282
- return browser.getVideoType(replayElement);
283
- };
284
-
285
- function pause(cb) {
286
- /*
287
- * avoids race condition, inspired by
288
- * http://stackoverflow.com/questions/36803176/how-to-prevent-the-play-request-was-interrupted-by-a-call-to-pause-error
289
- */
290
- setTimeout(() => {
291
- try {
292
- replayElement.pause();
293
- } catch (exc) {
294
- // just ignore, see https://github.com/binarykitchen/videomail.io/issues/386
295
- options.logger.warn(exc);
296
- }
297
-
298
- cb && cb();
299
- }, 15);
300
- }
301
-
302
- function play() {
303
- if (replayElement && replayElement.play) {
304
- let p;
305
-
306
- try {
307
- p = replayElement.play();
308
- } catch (exc) {
309
- /*
310
- * this in the hope to catch InvalidStateError, see
311
- * https://github.com/binarykitchen/videomail-client/issues/149
312
- */
313
- options.logger.warn("Caught replay exception:", exc);
314
- }
315
-
316
- if (p && typeof Promise !== "undefined" && p instanceof Promise) {
317
- p.catch((reason) => {
318
- options.logger.warn("Caught pending replay promise exception: %s", reason);
319
- });
320
- }
321
- }
322
- }
323
-
324
- this.reset = function (cb) {
325
- // pause video to make sure it won't consume any memory
326
- pause(() => {
327
- if (replayElement) {
328
- self.setMp4Source(null);
329
- self.setWebMSource(null);
330
- }
331
-
332
- cb && cb();
333
- });
334
- };
335
-
336
- this.hide = function () {
337
- if (isStandalone()) {
338
- hidden(parentElement, true);
339
- } else {
340
- replayElement && hidden(replayElement, true);
341
- }
342
- };
343
-
344
- this.isShown = function () {
345
- return replayElement && !hidden(replayElement);
346
- };
347
-
348
- this.getParentElement = function () {
349
- return parentElement;
350
- };
351
- };
352
-
353
- inherits(Replay, EventEmitter);
354
-
355
- export default Replay;