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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Adding sound effect after I click a certain widget

potatochips
13-Aquamarine

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

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

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

Top Tags