Skip to:
Content

BuddyPress.org

Ticket #6425: 6425.01.patch

File 6425.01.patch, 1.1 KB (added by r-a-y, 10 years ago)
  • src/bp-core/js/webcam.js

    diff --git src/bp-core/js/webcam.js src/bp-core/js/webcam.js
    index 2584465..a20047a 100644
    window.bp = window.bp || {}; 
    2525                                flipped:        false
    2626                        };
    2727
     28                        this.testWebCam();
     29
    2830                        bp.Avatar.nav.on( 'bp-avatar-view:changed', _.bind( this.setView, this ) );
    2931                },
    3032
     33                testWebCam: function() {
     34                        // camera is already disabled via code snippet
     35                        var cameraTab = jQuery('#bp-avatar-camera');
     36                        if ( cameraTab.length === 0 ) {
     37                                return false;
     38                        }
     39
     40                        var getUserMedia = navigator.getUserMedia || navigator.oGetUserMedia || navigator.mozGetUserMedia || navigator.webkitGetUserMedia || navigator.msGetUserMedia;
     41
     42                        if ( getUserMedia ) {
     43                                getUserMedia = getUserMedia.bind(navigator);
     44
     45                                getUserMedia(
     46                                        {video: true},
     47
     48                                        // success callback
     49                                        function (stream) {
     50                                        },
     51
     52                                        // error callback
     53                                        function (error) {
     54                                                cameraTab.remove();
     55                                        }
     56                                )
     57
     58                        // no support; drop camera tab
     59                        } else {
     60                                cameraTab.remove();
     61                        }
     62                },
     63
    3164                setView: function( view ) {
    3265                        if ( 'camera' !== view ) {
    3366                                // Stop the camera if needed