/* js*/of Sound$ (function() {var file =[]; file[' mp3 '] = '. /.. /content/music/1.mp3 '; Audioplayer (' Audioplane ', file, True); $ ("#voicebtn"). Click (function() {if ($ (this). Hasclass ("Voicebtn")) {$ (this). Removeclass ("Voicebtn"). AddClass ("Novoicebtn").); Audioplayer (' Audioplane '); } else{$ (this). Removeclass ("Novoicebtn"). AddClass ("Voicebtn"); Audioplayer (' Audioplane ', file, True); } }); });/* Fill and discard card full pressure other sound */functionVoice () {}/* Usage example: var file = []; file[' mp3 '] = ' 1.mp3 '; file[' ogg '] = ' 1.ogg '; Play Audioplayer (' Audioplane ', file, true); Stop Audioplayer (' Audioplane '); *//** music player * @param obj player ID * @param file Audio file mp3:ogg: * @param loop */functionAudioplayer (ID, file, loop) {var audioplayer =document.getElementById (ID); if (audioplayer!=null{Document.body.removeChild (audioplayer);} if (typeof (file)! = ' undefined ') {if (Navigator.userAgent.indexOf ("MSIE") >0 ) {//IE var player = document.createelement (' Bgsound ') ); Player.id = id; player.src = file[' mp3 ' ]; Player.setattribute (' Autostart ', ' true ' ); if (loop) { Player.setattribute (' Loop ', ' infinite ' );} document.body.appendChild (player); }else {//other FF chome Safari Opera var player = document.createelement (' audio ' ); player.id = id; play Er.setattribute (' AutoPlay ', ' AutoPlay ' ), if (loop) {player.setattribute (' Loop ', ' Loop ' );} Document.body.appendChild (player); var mp3 = document.createelement (' source ' ); mp3.src = file[' mp3 ' ]; mp3.type = ' audio/mpeg ' ; Player.appendchild (mp3); var ogg = document.createelement (' source ' ); ogg.src = file[' ogg ' ]; ogg.type = ' Audio/ogg ' ; Player.appendchild (OGG); } }}
JS Call to play Music