|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
-
- function AudioTagSample() {
-
- // initialize audio player
- this.audio = new Audio();
- this.isPlaying = false;
-
-
- window.addEventListener('load', this.onload.bind(this), false);
- }
-
- AudioTagSample.prototype.onload = function() {
- // Create the audio nodes.
- this.source = context.createMediaElementSource(this.audio);
-
- this.source.connect(context.destination);
- };
-
- AudioTagSample.prototype.click = function(link) {
-
- var was_inactive = this.audio.paused
- var was_the_same = this.audio.src == link.href
-
- var controls = document.querySelectorAll('.controls');
- for (i=0;i<controls.length;i++){
- controls[i].classList.toggle("playing");
- controls[i].classList.remove("fresh");
- };
-
- if (was_the_same) {
- if (this.audio.paused) {
- this.audio.play();
- link.classList.remove("paused")
- link.classList.add("playing")
- } else {
- this.audio.pause();
- link.classList.remove("playing")
- link.classList.add("paused")
- }
-
- } else {
- if(this.link) {
- this.link.classList.remove("playing")
- this.link.classList.remove("paused")
- }
- this.audio.src = link.href;
- this.link = link
- this.audio.play();
- link.classList.remove("paused")
- link.classList.add("playing")
- }
-
- if (was_inactive) {
- requestAnimFrame(this.draw.bind(this));
- }
- this.link = link;
- };
-
-
|