react-media-recorder
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -1,1 +0,1 @@ | ||
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var React=_interopDefault(require("react")),PropTypes=_interopDefault(require("prop-types")),asyncToGenerator=function(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,r){return function o(n,a){try{var i=t[n](a),s=i.value}catch(e){return void r(e)}if(!i.done)return Promise.resolve(s).then(function(e){o("next",e)},function(e){o("throw",e)});e(s)}("next")})}},classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},inherits=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},possibleConstructorReturn=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},ReactMediaRecorder=function(e){function t(e){var r=this;classCallCheck(this,t);var o=possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));if(o.state={status:"idle"},o.chunks=[],o.componentDidMount=asyncToGenerator(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.getMediaStream();case 2:o.stream=e.sent,o.stream||o.setState({status:"permission_denied"});case 4:case"end":return e.stop()}},e,r)})),o.getMediaStream=asyncToGenerator(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,window.navigator.mediaDevices.getUserMedia(o.requiredMedia);case 3:return t=e.sent,e.abrupt("return",t);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",!1);case 10:case"end":return e.stop()}},e,r,[[0,7]])})),o.onRecordingStop=function(){var e=new Blob(o.chunks,o.blobPropertyBag),t=URL.createObjectURL(e);o.setState({mediaBlob:t})},o.onRecordingActive=function(e){var t=e.data;o.chunks.push(t)},o.initMediaRecorder=function(e){var t=new MediaRecorder(e);return t.ondataavailable=o.onRecordingActive,t.onstop=o.onRecordingStop,t.onerror=function(){return o.setState({status:"recorder_error"})},t},o.startRecording=asyncToGenerator(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(o.stream&&(!o.stream||o.stream.active)){e.next=10;break}return e.next=3,o.getMediaStream();case 3:if(!(t=e.sent)){e.next=8;break}o.stream=t,e.next=10;break;case 8:return o.setState({status:"permission_denied"}),e.abrupt("return");case 10:o.mediaRecorder=o.initMediaRecorder(o.stream),o.chunks=[],o.setState({mediaBlob:null}),o.mediaRecorder.start(),o.setState({status:"recording"});case 15:case"end":return e.stop()}},e,r)})),o.stopRecording=function(){o.mediaRecorder&&"inactive"!==o.mediaRecorder.state&&(o.mediaRecorder.stop(),o.setState({status:"stopped"}))},o.render=function(){return o.props.render({status:o.state.status,startRecording:o.startRecording,stopRecording:o.stopRecording,mediaBlob:o.state.mediaBlob})},!window.MediaRecorder)throw new Error("React Media Recorder: Unsupported browser");var n=e.audio,a=e.video,i=e.blobPropertyBag,s=void 0===i?a?{type:"video/mp4"}:{type:"audio/wav"}:i;return o.requiredMedia={audio:"boolean"==typeof n?!!n:n,video:"boolean"==typeof a?!!a:a},o.blobPropertyBag=s,o}return inherits(t,e),t}(React.Component);ReactMediaRecorder.propTypes={audio:PropTypes.oneOfType([PropTypes.bool,PropTypes.object]),video:PropTypes.oneOfType([PropTypes.bool,PropTypes.object]),render:PropTypes.func.isRequired,blobPropertyBag:PropTypes.object},ReactMediaRecorder.defaultProps={audio:!0,render:function(){return null}},module.exports=ReactMediaRecorder; | ||
module.exports = require("./lib"); |
@@ -1,1 +0,1 @@ | ||
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var React=_interopDefault(require("react")),PropTypes=_interopDefault(require("prop-types")),asyncToGenerator=function(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,r){return function o(n,a){try{var i=t[n](a),s=i.value}catch(e){return void r(e)}if(!i.done)return Promise.resolve(s).then(function(e){o("next",e)},function(e){o("throw",e)});e(s)}("next")})}},classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},inherits=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},possibleConstructorReturn=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},ReactMediaRecorder=function(e){function t(e){var r=this;classCallCheck(this,t);var o=possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));if(o.state={status:"idle"},o.chunks=[],o.componentDidMount=asyncToGenerator(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.getMediaStream();case 2:o.stream=e.sent,o.stream||o.setState({status:"permission_denied"});case 4:case"end":return e.stop()}},e,r)})),o.getMediaStream=asyncToGenerator(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,window.navigator.mediaDevices.getUserMedia(o.requiredMedia);case 3:return t=e.sent,e.abrupt("return",t);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",!1);case 10:case"end":return e.stop()}},e,r,[[0,7]])})),o.onRecordingStop=function(){var e=new Blob(o.chunks,o.blobPropertyBag),t=URL.createObjectURL(e);o.setState({mediaBlob:t})},o.onRecordingActive=function(e){var t=e.data;o.chunks.push(t)},o.initMediaRecorder=function(e){var t=new MediaRecorder(e);return t.ondataavailable=o.onRecordingActive,t.onstop=o.onRecordingStop,t.onerror=function(){return o.setState({status:"recorder_error"})},t},o.startRecording=asyncToGenerator(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(o.stream&&(!o.stream||o.stream.active)){e.next=10;break}return e.next=3,o.getMediaStream();case 3:if(!(t=e.sent)){e.next=8;break}o.stream=t,e.next=10;break;case 8:return o.setState({status:"permission_denied"}),e.abrupt("return");case 10:o.mediaRecorder=o.initMediaRecorder(o.stream),o.chunks=[],o.setState({mediaBlob:null}),o.mediaRecorder.start(),o.setState({status:"recording"});case 15:case"end":return e.stop()}},e,r)})),o.stopRecording=function(){o.mediaRecorder&&"inactive"!==o.mediaRecorder.state&&(o.mediaRecorder.stop(),o.setState({status:"stopped"}))},o.render=function(){return o.props.render({status:o.state.status,startRecording:o.startRecording,stopRecording:o.stopRecording,mediaBlob:o.state.mediaBlob})},!window.MediaRecorder)throw new Error("React Media Recorder: Unsupported browser");var n=e.audio,a=e.video,i=e.blobPropertyBag,s=void 0===i?a?{type:"video/mp4"}:{type:"audio/wav"}:i;return o.requiredMedia={audio:"boolean"==typeof n?!!n:n,video:"boolean"==typeof a?!!a:a},o.blobPropertyBag=s,o}return inherits(t,e),t}(React.Component);ReactMediaRecorder.propTypes={audio:PropTypes.oneOfType([PropTypes.bool,PropTypes.object]),video:PropTypes.oneOfType([PropTypes.bool,PropTypes.object]),render:PropTypes.func.isRequired,blobPropertyBag:PropTypes.object},ReactMediaRecorder.defaultProps={audio:!0,render:function(){return null}},module.exports=ReactMediaRecorder; | ||
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var React=_interopDefault(require("react")),PropTypes=_interopDefault(require("prop-types"));class ReactMediaRecorder extends React.Component{constructor(e){if(super(e),this.state={status:"idle"},this.chunks=[],this.componentDidMount=(async()=>{this.stream=await this.getMediaStream(),this.stream||this.setState({status:"permission_denied"})}),this.getMediaStream=(async()=>{try{return await window.navigator.mediaDevices.getUserMedia(this.requiredMedia)}catch(e){return!1}}),this.onRecordingStop=(()=>{const e=new Blob(this.chunks,this.blobPropertyBag),t=URL.createObjectURL(e);this.setState({mediaBlob:t})}),this.onRecordingActive=(({data:e})=>{this.chunks.push(e)}),this.initMediaRecorder=(e=>{const t=new MediaRecorder(e);return t.ondataavailable=this.onRecordingActive,t.onstop=this.onRecordingStop,t.onerror=(()=>this.setState({status:"recorder_error"})),t}),this.startRecording=(async()=>{if(!this.stream||this.stream&&!this.stream.active){const e=await this.getMediaStream();if(!e)return void this.setState({status:"permission_denied"});this.stream=e}this.mediaRecorder=this.initMediaRecorder(this.stream),this.chunks=[],this.setState({mediaBlob:null}),this.mediaRecorder.start(),this.setState({status:"recording"})}),this.stopRecording=(()=>{this.mediaRecorder&&"inactive"!==this.mediaRecorder.state&&(this.mediaRecorder.stop(),this.setState({status:"stopped"}))}),this.render=(()=>this.props.render({status:this.state.status,startRecording:this.startRecording,stopRecording:this.stopRecording,mediaBlob:this.state.mediaBlob})),!window.MediaRecorder)throw new Error("React Media Recorder: Unsupported browser");const{audio:t,video:r,blobPropertyBag:i=(r?{type:"video/mp4"}:{type:"audio/wav"})}=e;this.requiredMedia={audio:"boolean"==typeof t?!!t:t,video:"boolean"==typeof r?!!r:r},this.blobPropertyBag=i}}ReactMediaRecorder.propTypes={audio:PropTypes.oneOfType([PropTypes.bool,PropTypes.object]),video:PropTypes.oneOfType([PropTypes.bool,PropTypes.object]),render:PropTypes.func.isRequired,blobPropertyBag:PropTypes.object},ReactMediaRecorder.defaultProps={audio:!0,render:()=>null},module.exports=ReactMediaRecorder; |
{ | ||
"name": "react-media-recorder", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": | ||
@@ -5,0 +5,0 @@ "A React component based on MediaRecorder() API to record audio/video streams", |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
2
7669
10
1