videomail-client 4.0.0 → 5.0.0

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.
@@ -45,6 +45,8 @@ const Browser = function (options) {
45
45
 
46
46
  const self = this
47
47
 
48
+ let videoType
49
+
48
50
  function getRecommendation() {
49
51
  let warning
50
52
 
@@ -145,7 +147,6 @@ const Browser = function (options) {
145
147
  return warning
146
148
  }
147
149
 
148
- // just temporary
149
150
  this.canRecord = function () {
150
151
  const hasNavigator = typeof navigator !== 'undefined'
151
152
  let canRecord = false
@@ -240,6 +241,43 @@ const Browser = function (options) {
240
241
  return err
241
242
  }
242
243
 
244
+ function canPlayType(video, type) {
245
+ let canPlayType
246
+
247
+ if (video && video.canPlayType) {
248
+ canPlayType = video.canPlayType('video/' + type)
249
+ }
250
+
251
+ // definitely cannot be played here
252
+ if (canPlayType === '') {
253
+ return false
254
+ }
255
+
256
+ return canPlayType
257
+ }
258
+
259
+ this.getVideoType = function (video) {
260
+ if (!video) {
261
+ // no type without video
262
+ return
263
+ }
264
+
265
+ if (!videoType) {
266
+ if (canPlayType(video, 'webm')) {
267
+ videoType = 'webm'
268
+ } else if (canPlayType(video, 'mp4')) {
269
+ videoType = 'mp4'
270
+ }
271
+ }
272
+
273
+ if (!videoType || videoType === '') {
274
+ // just as a fallback
275
+ videoType = 'webm'
276
+ }
277
+
278
+ return videoType
279
+ }
280
+
243
281
  this.getNoAccessIssue = function () {
244
282
  const message = 'Unable to access webcam'
245
283
  let explanation
@@ -850,7 +850,8 @@ const Recorder = function (visuals, replay, defaultOptions = {}) {
850
850
  wantedInterval: 1e3 / options.video.fps,
851
851
 
852
852
  intervalSum: getIntervalSum(),
853
- framesCount: framesCount
853
+ framesCount: framesCount,
854
+ videoType: replay.getVideoType()
854
855
  }
855
856
 
856
857
  if (options.isAudioEnabled()) {
@@ -84,8 +84,6 @@ const Replay = function (parentElement, options) {
84
84
  this.setWebMSource(videomail.webm)
85
85
  }
86
86
 
87
- // We are not serving MP4 videos anymore due to licensing but are keeping code
88
- // for compatibility and documentation
89
87
  if (videomail.mp4) {
90
88
  this.setMp4Source(videomail.mp4)
91
89
  }