Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-4191

add possibility to handle camera unavailability

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Done
    • Icon: Normal Normal
    • 8.6.1
    • 8.6.0.1
    • Components
    • Security Level: Jimmy
    • ZK 8.6.1 S1

      current prototypic idea:

      		zk.afterLoad('zkmax.med', function() {
      			var xCamera = {};
      			zk.override(zkmax.med.Camera.prototype, xCamera, {
      				requestCamera : function(callback, handleError) { //second optional parameter allows customization when calling the requestCamera
      					var wgt = this,
      						video = this.$n('real'),
      						constraints = this.getConstraints() || {audio: this._audio, video: true};
      
      					navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia ||
      									navigator.mozGetUserMedia || navigator.msGetUserMedia ||
      									navigator.oGetUserMedia || navigator.mediaDevices.getUserMedia;
      
      					navigator.getUserMedia(constraints,
      						function (stream) {
      							if (callback) {
      								window.setTimeout(function () {
      									callback();
      								}, 500);
      							}
      							wgt._settingPreview(wgt._previewRecord);
      							video.srcObject = stream;
      						},
      						handleError || this.handleCameraUnavailable;
      					);
      				},
      
      				//widget method allowing to override globally
      				handleCameraUnavailable: function(error) {
      					this.fire('onCameraUnavailable', {error: error});
      				}
      			});//zk.override
      		});//zk.afterLoad
      

      also worth considering to return the promise directly

            CharlesQiu CharlesQiu
            cor3000 cor3000
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 1 day
                1d
                Remaining:
                Time Spent - 4 hours Remaining Estimate - 4 hours
                4h
                Logged:
                Time Spent - 4 hours Remaining Estimate - 4 hours
                4h