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

Adding sound effect after I click a certain widget

SOLVED
jc2
Garnet

Adding sound effect after I click a certain widget

Hi all,

I want to create a function that when a button is click a certain sound effect will appear. Is there a js code for this?

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Adding sound effect after I click a certain widget

use this Script, and associate this function to Click or another event of Widget.

 

$scope.mp3play=function() {

var audioElement;
if(!audioElement) {
audioElement = document.createElement('audio');
audioElement.innerHTML = '<source src="' + 'app/resources/Uploaded/File_Name.mp3'+ '" type="audio/mpeg" />'
}
audioElement.play();
};

 

File_Name.mp3 = name of file  saved into resource of project.

it has been tested and is working on  Tablet (Android & IOS) ,Mobile (Android & IOS), Hololens.

 

 

I HOPE TO HELP YOU

Giuseppe

View solution in original post

1 REPLY 1

Re: Adding sound effect after I click a certain widget

use this Script, and associate this function to Click or another event of Widget.

 

$scope.mp3play=function() {

var audioElement;
if(!audioElement) {
audioElement = document.createElement('audio');
audioElement.innerHTML = '<source src="' + 'app/resources/Uploaded/File_Name.mp3'+ '" type="audio/mpeg" />'
}
audioElement.play();
};

 

File_Name.mp3 = name of file  saved into resource of project.

it has been tested and is working on  Tablet (Android & IOS) ,Mobile (Android & IOS), Hololens.

 

 

I HOPE TO HELP YOU

Giuseppe

View solution in original post

Announcements
Topics available:
AR/VR for Data Optimization AR/VR for Security and Control AR/VR for Inspection