carlosj Posted September 9, 2013 Share Posted September 9, 2013 (edited) Hi, I would like to solve a little but annoying detail on my site. I am using the html5 <audio tag> to make a simple audio player that has several files and would love to be able to implement this little detail: I want it to stop the audio when any other file is selected to be played. Right now if you hit play, and a preceding file is on play...well ... both sound at the same time. So I simply want to implement some kind of rule to play ONLY the last selected one. Is this possible? Please have in mind that I am not a skillful programmer or any thing. I know just a enough to copy code here and there. Thanks in advance to any one who could help me out. Best regards. Edited September 9, 2013 by carlosj Link to comment Share on other sites More sharing options...
harpalsinh999 Posted September 9, 2013 Share Posted September 9, 2013 http://www.w3schools.com/html/html5_audio.asp here your information Link to comment Share on other sites More sharing options...
carlosj Posted September 9, 2013 Author Share Posted September 9, 2013 Thanks for the link. But that is pretty much what I have already, but does not play only last selected one. Link to comment Share on other sites More sharing options...
harpalsinh999 Posted September 9, 2013 Share Posted September 9, 2013 (edited) <audio id="sample" src="sounds.mp3"></audio><a href="javascript:play1();">Play1</a><a href="javascript:play2();">Play2</a><a href="javascript:pauseAudio();">Pause</a><script>var audio = document.getElementById('click');function play1(){audio.currentTime = 0;audio.play();// This is the problem areaaudio.addEventListener('timeupdate', function (){if (currentTime >= 0.5) {audio.pause();}}, false);} function play2(){audio.currentTime = 0.5;audio.play();}function pause(){audio.pause();}</script> it possible in javascript http://stackoverflow.com/questions/5932412/html5-audio-how-to-play-only-a-selected-portion-of-an-audio-file-audio-sprite go this link Edited September 9, 2013 by harpalsinh999 Link to comment Share on other sites More sharing options...
harpalsinh999 Posted September 9, 2013 Share Posted September 9, 2013 or http://stackoverflow.com/questions/15385634/how-to-use-the-selected-audio-file-using-javascript-via-audio-tag-in-html-5 Link to comment Share on other sites More sharing options...
harpalsinh999 Posted September 9, 2013 Share Posted September 9, 2013 (edited) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><script type="text/javascript"><!--function song(){document.getElementById('music1').innerHTML="<embed type='application/x-mplayer2' id='music2' pluginspage='http://www.microsoft.com/Windows/MediaPlayer/' src='"+document.getElementById('cancion').value+"' name='MediaPlayer1' width='300' height='70' controltype='2' showcontrols='1' showstatusbar='1' AutoStart='true'></embed>";}//--></script></head><body><div style="text-align:center;"><select name="" id="cancion" onchange="song()" size="1"><option value="none">::::::::::::: Choose Your Song Here :::::::::::::</option><option value="http://urltosong1.mp3">Song 1</option><option value="http://urltosong2.mp3">Song 2</option><option value="http://urltosong3.mp3">Song 3</option><option value="http://urltosong4.mp3">Song 4</option><option value="http://urltosong5.mp3">Song 5</option> </select><br><span id="music1"><embed type="application/x-mplayer2" id="music1"pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"src=""name="MediaPlayer1"width="300"height="70"controltype="2"showcontrols="1"showstatusbar="1"AutoStart="0"></embed></span></div></body></html> Edited September 9, 2013 by harpalsinh999 Link to comment Share on other sites More sharing options...
carlosj Posted September 9, 2013 Author Share Posted September 9, 2013 (edited) THANKS!!! Hope I can manage... LOL Edited September 9, 2013 by carlosj Link to comment Share on other sites More sharing options...
harpalsinh999 Posted September 9, 2013 Share Posted September 9, 2013 u use my last post ok Link to comment Share on other sites More sharing options...
carlosj Posted September 9, 2013 Author Share Posted September 9, 2013 I was wondering... is there a plugin involved ? From my experience, which is not much, the plugin thing is a problem since not every body has all the plugins installed. Thanks ! Link to comment Share on other sites More sharing options...
harpalsinh999 Posted September 10, 2013 Share Posted September 10, 2013 u use only select and option tag not use plugin Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now