JS Call to play Music

Source: Internet
Author: User

/* 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.