jquery and audio embedding
-
I’m trying to use the CSS & Javascript Toolbox plugin to add javascript to my main page that plays audio, but it isn’t working. Here is the code I am using:
<audio id="audio" preload="auto" tabindex="0" controls="" type="audio/ogg" style="display: none;"> </audio> <div id="playing" style="display: none;"> </div> <script> var audio; var playlist; var tracks; var current; var musicarr = ["https://domain/siteaudio.ogg", "https://domain/siteaudio2.ogg", "https://domain/siteaudio3.ogg", "https://domain/siteaudio4.ogg", "https://domain/siteaudio5.ogg", "https://domain/siteaudio6.ogg", "https://domain/images/siteaudio7.ogg", "https://domain/siteaudio8.ogg", "https://domain/siteaudio9.ogg", "https://domain/siteaudio10.ogg", "https://domain/siteaudio11.ogg", "https://domain/siteaudio12.ogg", "https://domain/siteaudio13.ogg", "https://domain/siteaudio14.ogg",]; shuffle(musicarr); init(); function init(){ current = 0; audio = $('audio'); audio[0].volume = .20; len = musicarr.length; run(musicarr[current], audio[0]); } function run(link, player){ player.src = link; audio[0].load(); audio[0].play(); $('#playing').html("<ul><li><a>" + link+ "</a></li></ul>"); } function shuffle(array) { var currentIndex = array.length, temporaryValue, randomIndex ; // While there remain elements to shuffle... while (0 !== currentIndex) { // Pick a remaining element... randomIndex = Math.floor(Math.random() * currentIndex); currentIndex -= 1; // And swap it with the current element. temporaryValue = array[currentIndex]; array[currentIndex] = array[randomIndex]; array[randomIndex] = temporaryValue; } return array; } </script>
I have code for MP3 as well. That is just ogg. Can someone tell me how to use this code? TIA!
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘jquery and audio embedding’ is closed to new replies.