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

Assigning multiple audios to single button

Highlighted
Participant

Assigning multiple audios to single button

Can you please help me to link multiple audio files to a single button, so that on pressing the same button I can play multiple audio files assigned to different animation sequences, to create AR in vuforia studio
2 REPLIES 2

Re: Assigning multiple audios to single button

How do you plan on updating the sequence for your model? You can use JS to update the audio source for a single audio widget based on which sequence is loaded. 

 

If you are using a select widget to pick the sequence, you could do something like this: 

 

$scope.checkSequence = function(){ 
  var sequenceValue= $scope.app.view['Home'].wdg['select-1']['value'];
  var sequenceList = $scope.app.view['Home'].wdg['select-1']['list'];


  for (i = 0; i < sequenceList.length; i++){
    var sequence = sequenceList[i].filename;
     if (sequence == sequenceValue){
        switch(i){
          case 0:
            $scope.view.wdg.sequenceAudio.audiosrc='app/resources/Uploaded/<your audio file>';
            break;
          case 1:
            $scope.view.wdg.sequenceAudio.audiosrc='app/resources/Uploaded/<your audio file>';
            break;
          case 2:
            $scope.view.wdg.sequenceAudio.audiosrc='app/resources/Uploaded/<your audio file>';
            break;
          default:
            console.log('in change audio');
        }
    }
  }
}

 

 

Call this function on the "Value Changed' Event for your 2D selector

 

If you want to use the same 'play' button that you're using to play the sequence, you can call a small function like the below on the button click event. 

$scope.playAudio = function(){
    twx.app.fn.triggerWidgetService('sequenceAudio', 'play');
}

 

For steps to set up the select widget see this community post: https://community.ptc.com/t5/Vuforia-Studio/Select-Widget-default-value/m-p/611653

Re: Assigning multiple audios to single button

Thank you for the response. I tried creating the experience but still am not able to make it. I have created a separate play button on the 2D canvas, by clicking on which we can play different sequences of animation. I have multiple audio files denoting each sequence separately by names Audio1, Audio2.... and so on. I want to link these audio files to the same button so that with each sequence the corresponding audio plays. Can you please provide me with the Javascript to upload in the format.