text: // Muaz Khan     - https://github.com/muaz-khan 
  // neizerth      - https://github.com/neizerth
  // MIT License   - https://www.webrtc-experiment.com/licence/
  // Documentation - https://github.com/streamproc/MediaStreamRecorder
  // ==========================================================
  // MediaStreamRecorder.js
  
  function MediaStreamRecorder(mediaStream) {
      if (!mediaStream) throw 'MediaStream is mandatory.';
  
      // void start(optional long timeSlice)
      // timestamp to fire "ondataavailable"
      this.start = function(timeSlice) {
          // Media Stream Recording API has not been implemented in chrome yet;
          // That's why using WebAudio API to record stereo audio in WAV format
          var Recorder = IsChrome ? window.StereoRecorder : window.MediaRecorder;
  
          // video recorder (in WebM format)
          if (this.mimeType === 'video/webm') Recorder = window.WhammyRecorder;
  
          // video recorder (in GIF format)
          if (this.mimeType === 'image/gif') Recorder = window.GifRecorder;
  
          mediaRecorder = new Recorder(mediaStream);
          mediaRecorder.ondataavailable = this.ondataavailable;
          mediaRecorder.onstop = this.onstop;
  
          // Merge all data-types except "function"
          mediaRecorder = mergeProps(mediaRecorder, this);
  
          mediaRecorder.start(timeSlice);
      };
  
      this.stop = function() {
          if (mediaRecorder) mediaRecorder.stop();
      };
  
      this.ondataavailable = function(blob) {
          console.log('ondataavailable..', blob);
      };
  
      this.onstop = function() {
          console.log('stopped..');
      };
  
      // Reference to "MediaRecorder.js"
      var mediaRecorder;
  }
  
  // ==========================
  // Cross-Browser Declarations
  
  // Media Stream Recording API representer
  MediaRecorderWrapper = window.MediaRecorder;
  
  // animation-frame used in WebM recording
  requestAnimationFrame = window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;
  cancelAnimationFrame = window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame;
  
  // WebAudio API representer
  AudioContext = window.webkitAudioContext || window.mozAudioContext;
  
  URL = window.URL || window.webkitURL;
  navigator.getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
  
  IsChrome = !!navigator.webkitGetUserMedia;
  
  // Merge all other data-types except "function"
  function mergeProps(mergein, mergeto) {
      for (var t in mergeto) {
          if (typeof mergeto[t] !== 'function') {
              mergein[t] = mergeto[t];
          }
      }
      return mergein;
  }
  