Changeset 12548 for trunk/src/bp-core/js/webcam.js
- Timestamp:
- 01/29/2020 10:04:53 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/js/webcam.js
r11944 r12548 5 5 ( function() { 6 6 7 // Bail if not set 7 // Bail if not set. 8 8 if ( typeof BP_Uploader === 'undefined' ) { 9 9 return; … … 31 31 setView: function( view ) { 32 32 if ( 'camera' !== view ) { 33 // Stop the camera if needed 33 // Stop the camera if needed. 34 34 if ( ! _.isNull( this.params.video ) ) { 35 35 this.stop(); 36 36 37 // Remove all warnings as we're changing the view 37 // Remove all warnings as we're changing the view. 38 38 this.removeWarning(); 39 39 } 40 40 41 // Stop as this is not Camera area 42 return; 43 } 44 45 // Create the WebCam view 41 // Stop as this is not Camera area. 42 return; 43 } 44 45 // Create the WebCam view. 46 46 var cameraView = new bp.Views.WebCamAvatar( { model: new Backbone.Model( { user_media: false } ) } ); 47 47 48 // Make sure the flipped param is reset 48 // Make sure the flipped param is reset. 49 49 this.params.flipped = false; 50 50 51 // Add it to views 51 // Add it to views. 52 52 bp.Avatar.views.add( { id: 'camera', view: cameraView } ); 53 53 54 // Display it 54 // Display it. 55 55 cameraView.inject( '.bp-avatar' ); 56 56 }, … … 70 70 bp.WebCam.params.videoStream = stream; 71 71 72 // User Feedback 72 // User Feedback. 73 73 bp.WebCam.displayWarning( 'loaded' ); 74 74 75 75 video.onerror = function () { 76 // User Feedback 76 // User Feedback. 77 77 bp.WebCam.displayWarning( 'videoerror' ); 78 78 … … 84 84 stream.onended = bp.WebCam.noStream(); 85 85 86 // Older browsers may not have srcObject 86 // Older browsers may not have srcObject. 87 87 if ( 'srcObject' in video ) { 88 88 video.srcObject = stream; … … 122 122 noStream: function() { 123 123 if ( _.isNull( bp.WebCam.params.videoStream ) ) { 124 // User Feedback 124 // User Feedback. 125 125 bp.WebCam.displayWarning( 'noaccess' ); 126 126 … … 134 134 } 135 135 136 // Remove the view 136 // Remove the view. 137 137 bp.WebCam.removeView(); 138 138 … … 157 157 }; 158 158 159 // BuddyPress WebCam view 159 // BuddyPress WebCam view. 160 160 bp.Views.WebCamAvatar = bp.View.extend( { 161 161 tagName: 'div', … … 181 181 182 182 if ( typeof navigator.getUserMedia !== 'undefined' ) { 183 // We need to add some cropping stuff to use bp.Avatar.setAvatar() 183 // We need to add some cropping stuff to use bp.Avatar.setAvatar(). 184 184 params = _.extend( _.pick( BP_Uploader.settings.defaults.multipart_params.bp_params, 185 185 'object', … … 217 217 bp.WebCam.params.canvas = this.options.canvas.el; 218 218 219 // User Feedback 219 // User Feedback. 220 220 bp.WebCam.displayWarning( 'requesting' ); 221 221 … … 235 235 // ES3 compatibility. 236 236 ['catch'](function() { 237 // User Feedback 237 // User Feedback. 238 238 bp.WebCam.displayWarning( 'errormsg' ); 239 239 }); … … 246 246 247 247 if ( ! bp.WebCam.params.capture_enable ) { 248 // User Feedback 248 // User Feedback. 249 249 bp.WebCam.displayWarning( 'loading' ); 250 250 return; … … 256 256 } 257 257 258 // Set the offset 258 // Set the offset. 259 259 sc = this.options.video.el.videoHeight; 260 260 sx = ( this.options.video.el.videoWidth - sc ) / 2; … … 271 271 this.model.set( 'url', bp.WebCam.params.capture ); 272 272 273 // User Feedback 273 // User Feedback. 274 274 bp.WebCam.displayWarning( 'ready' ); 275 275 }, … … 279 279 280 280 if ( ! bp.WebCam.params.capture ) { 281 // User Feedback 281 // User Feedback. 282 282 bp.WebCam.displayWarning( 'nocapture' ); 283 283 return; … … 289 289 } ); 290 290 291 // BuddyPress Video stream view 291 // BuddyPress Video stream view. 292 292 bp.Views.WebCamVideo = bp.View.extend( { 293 293 tagName: 'video', … … 298 298 } ); 299 299 300 // BuddyPress Canvas (capture) view 300 // BuddyPress Canvas (capture) view. 301 301 bp.Views.WebCamCanvas = bp.View.extend( { 302 302 tagName: 'canvas', … … 308 308 309 309 initialize: function() { 310 // Make sure to take in account bp_core_avatar_full_height or bp_core_avatar_full_width php filters 310 // Make sure to take in account bp_core_avatar_full_height or bp_core_avatar_full_width php filters. 311 311 if ( ! _.isUndefined( BP_Uploader.settings.crop.full_h ) && ! _.isUndefined( BP_Uploader.settings.crop.full_w ) ) { 312 312 this.el.attributes.width.value = BP_Uploader.settings.crop.full_w;
Note: See TracChangeset
for help on using the changeset viewer.