audio-play-pause

by dledet1

HTML

<!-- AUDIO 1 -->
                  <p><a onClick="EvalSound('song1'); return true;"
                      target="player"><IMG SRC="http://designlab360.org/fhi/splash/dev2/images/arrow-right.png" BORDER=0 WIDTH=30 HEIGHT=29>
</A>    
<audio id="song1" src="http://designlab360.org/fhi/splash/dev2/audio/wash-song1_2.mp3" controls preload="auto" autobuffer></audio>
				  <!-- AUDIO 2 -->
                  <p><a onClick="EvalSound('song2'); return true;"
    target="player"><IMG SRC="http://designlab360.org/fhi/splash/dev2/images/arrow-right.png" BORDER=0 WIDTH=30 HEIGHT=29>
</A>    
<audio id="song2" src="http://designlab360.org/fhi/splash/dev2/audio/wash-song2_2.mp3" controls preload="auto" autobuffer></audio></p>

JavaScript

var currentPlayer;
	function EvalSound(soundobj) {
	
	 var thissound=document.getElementById(soundobj);
	 if(currentPlayer  && currentPlayer != thissound) {
		  currentPlayer.pause(); 
	 }
	 if (thissound.paused)
				thissound.play();
		else
			thissound.pause();
			thissound.currentTime = 0;
			 currentPlayer = thissound;
	}