]> git.mxchange.org Git - friendica-addons.git/blob - jappixmini/jappix/js/audio.js
Merge pull request #520 from rabuzarus/20180206_-_membersince_frio_support
[friendica-addons.git] / jappixmini / jappix / js / audio.js
1 /*
2
3 Jappix - An open social platform
4 These are the audio JS scripts for Jappix
5
6 -------------------------------------------------
7
8 License: AGPL
9 Author: Vanaryon
10 Last revision: 10/08/11
11
12 */
13
14 // Plays the given sound ID
15 function soundPlay(num) {
16         try {
17                 // Not supported!
18                 if((BrowserDetect.browser == 'Explorer') && (BrowserDetect.version < 9))
19                         return false;
20                 
21                 // If the sounds are enabled
22                 if(getDB('options', 'sounds') == '1') {
23                         // If the audio elements aren't yet in the DOM
24                         if(!exists('#audio')) {
25                                 $('body').append(
26                                         '<div id="audio">' + 
27                                                 '<audio id="new-chat" src="./snd/new-chat.oga" type="audio/ogg" />' + 
28                                                 '<audio id="receive-message" src="./snd/receive-message.oga" type="audio/ogg" />' + 
29                                                 '<audio id="notification" src="./snd/notification.oga" type="audio/ogg" />' + 
30                                         '</div>'
31                                 );
32                         }
33                         
34                         // We play the target sound
35                         var playThis = document.getElementById('audio').getElementsByTagName('audio')[num];
36                         playThis.load();
37                         playThis.play();
38                 }
39         }
40         
41         catch(e) {}
42         
43         finally {
44                 return false;
45         }
46 }