cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Toggling mute and unmute for audio in vuforia studio / but also settig of the volumen control

RolandRaytchev
21-Topaz I

Toggling mute and unmute for audio in vuforia studio / but also settig of the volumen control

because so far I see,  the post  (question by @Ace_Rothstein ) is already closed and there is no possible to add a solution or  workaround  to this post, therefore I want to open extra topic for some further considerations of the issue and will  try to provide a solution /workaround  for this item. 

Following steps: 

1.)To be able to  get access to an audio or video widget first we need to receive the audio object. To get the  angular element object of the audio widget following js code could be used: 

 

 

 

var nameAudio="audio-1'
var myaudio = angular.element(document.querySelector('twx-widget[widget-id=\"'+nameAudio+'\"] audio'));

 

 

2.)The next step is to  set the value of the control mute property  to the  toggle value /  negated value  = ! toggle.value 

 e.g.:

 

 

 

let toggle =! $scope.view.wdg[nameToggle].value
myaudio[0].volume = toggle;
$scope.$applyAsync()

 

 

 

3.)you can define a function implementing the point 1 and 2 and set this function  to the toggle Wdiget UI JS Box change event:

 

2021-02-01_18-31-29.jpg

 

The function definition could be something like this:

 

 

 

$scope.toggleAudio  =  function(nameAudio,nameToggle) {
 var myaudio = angular.element(document.querySelector('twx-widget[widget-id=\"'+nameAudio+'\"] audio'));
 
let toggle =! $scope.view.wdg[nameToggle].value
 
 myaudio[0].volume = toggle;
  
  $scope.$applyAsync()
}

 

 

 

4.) Now when we test it - we will the desired behavior :

 

2021-02-01_18-33-55.jpg

I attached a project example which demonstrates the issue /implements a demo solution

ACCEPTED SOLUTION

Accepted Solutions

Great! That is an amazing solution. Precisely what I was looking for. 

View solution in original post

1 REPLY 1

Great! That is an amazing solution. Precisely what I was looking for. 

Announcements

Top Tags