Browse Source

test pause webrtc

Nikolay Suslov 7 years ago
parent
commit
eadefcc5ae

+ 24 - 0
public/webrtc/appui.js

@@ -58,6 +58,30 @@ function createApp() {
                                        
                                     }
     
+                                },
+                                {
+                                    $cell: true,
+                                    $type: "button",
+                                    class: "mdc-button mdc-button--raised",
+                                    $text: "Off",
+                                    onclick: function (e) {
+                                        let avatarID = 'avatar-'+vwf.moniker_;
+                                        vwf_view.kernel.callMethod(avatarID, "webrtcTurnOnOff", [false]);
+                                       
+                                    }
+    
+                                },
+                                {
+                                    $cell: true,
+                                    $type: "button",
+                                    class: "mdc-button mdc-button--raised",
+                                    $text: "On",
+                                    onclick: function (e) {
+                                        let avatarID = 'avatar-'+vwf.moniker_;
+                                        vwf_view.kernel.callMethod(avatarID, "webrtcTurnOnOff", [true]);
+                                       
+                                    }
+    
                                 }
     
     

+ 24 - 0
support/client/lib/vwf/view/webrtc.js

@@ -288,6 +288,13 @@ define( [ "module", "vwf/view", "vwf/utility", "vwf/utility/color", "jquery" ],
                         methodValue = setMute.call( this, methodParameters );
                     }
                     break;
+                
+                case "webrtcTurnOnOff":
+                    if ( this.kernel.moniker() == this.kernel.client() ) {
+                        methodValue = turnOnOffTracks.call( this, methodParameters );
+                    }
+                    break;    
+
             }
         },       
 
@@ -461,6 +468,23 @@ define( [ "module", "vwf/view", "vwf/utility", "vwf/utility/color", "jquery" ],
         setPause.call( this, !sharing.video );
     }
 
+    function turnOnOffTracks( mute ) {
+        let str = this.local.stream;
+        if ( str ) {
+            var audioTracks = str.getAudioTracks();
+            var videoTracks = str.getVideoTracks();
+
+            audioTracks.forEach(function(track) {
+                track.enabled = mute[0];
+              });
+
+              videoTracks.forEach(function(track) {
+                track.enabled = mute[0];
+              });
+        }
+    };
+
+   
 
     function setMute( mute ) {
         if ( this.local.stream && this.local.stream.audioTracks && this.local.stream.audioTracks.length > 0 ) {

+ 4 - 0
support/proxy/vwf.example.com/aframe/avatar.js

@@ -320,6 +320,10 @@ this.setVideoTexture = function(val){
     this.avatarNode.myHead.visual.src = '#'+val;
 }
 
+this.webrtcTurnOnOff = function(val){
+    console.log('WEBRTC is ', val);
+}
+
 this.initialize = function() {
    // this.future(0).updateAvatar();
 };

+ 3 - 0
support/proxy/vwf.example.com/aframe/avatar.vwf.yaml

@@ -31,5 +31,8 @@ methods:
     setVideoTexture:
         parameters:
             - val
+    webrtcTurnOnOff:
+        parameters:
+            - val
 scripts:
 - source: "http://vwf.example.com/aframe/avatar.js"