I'm building a music player and I'd like to add a pulsation effect depending on the track currently played.
Here some examples of what I'd want:
http://www.htmlfivewow.com/demos/hal/index.html
http://www.schillmania.com/projects/soundmanager2/demo/360-player/canvas-visualization.html
My problem is that in the first example, sound is loaded via xhr, and in the second it uses flash.
I'd want to be able to get the sound that I want to analyze from the audio tag.
I'm afraid it could not be possible, it would cause a big lack of security because we could load web pages instead of sound and then analyse it. Is there a solution anyway?
To embed audio in HTML, we use the <audio> tag. Before HTML5, audio cannot be added to web pages in the Internet Explorer era. To play audio, we used web plugins like Flash.
You can also use the <embed> tag or the newer <audio> tag to insert a sound file directly into a web page. With audio files, we recommend using the . MP3 file format because of its wide acceptance on the Internet, and is utilized by all browsers and operating systems.
Audio element shows just fine but as soon as you remove 'controls' from the audio tag, it disappears.
You can use createMediaElementSource method in AudioContext.
<audio id="audio" src="test.mp3"></audio>
<script type="text/javascript">
var context = new webkitAudioContext;
var el = document.getElementById('audio');
var source = context.createMediaElementSource(el);
source.connect(context.destination);
el.play();
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With