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, i.e the audio does not play. When I go to view-source:https://blog.systechforum.net/ and search for CSS & Javascript Toolbox I don’t see it which I guess means the plugin isn’t active. I have tried using the code in the Java script input and HTML input. My blog is blog.systechforum.net Here is the code I am using:
<audio id="audio" preload="auto" tabindex="0" controls="" type="audio/mpeg" style="display: none;"> </audio> <div id="playing" style="display: none;"> </div> <script> var audio; var playlist; var tracks; var current; var musicarr = ["https://www.systechforum.net/images/siteaudio.mp3", "https://www.systechforum.net/images/siteaudio2.mp3", "https://www.systechforum.net/images/siteaudio3.mp3", "https://www.systechforum.net/images/siteaudio4.mp3", "https://www.systechforum.net/images/siteaudio5.mp3", "https://www.systechforum.net/images/siteaudio6.mp3", "https://www.systechforum.net/images/siteaudio7.mp3", "https://www.systechforum.net/images/siteaudio8.mp3", "https://www.systechforum.net/images/siteaudio9.mp3", "https://www.systechforum.net/images/siteaudio10.mp3", "https://www.systechforum.net/images/siteaudio11.mp3", "https://www.systechforum.net/images/siteaudio12.mp3", "https://www.systechforum.net/images/siteaudio13.mp3", "https://www.systechforum.net/images/siteaudio14.mp3",]; 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!
https://www.ads-software.com/plugins/css-javascript-toolbox/
Viewing 14 replies - 1 through 14 (of 14 total)
Viewing 14 replies - 1 through 14 (of 14 total)
- The topic ‘jquery and audio embedding’ is closed to new replies.