Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2011
    Posts
    103

    Html5 audio player

    I found a tut on the internet on how to create a simple HTML 5 audio player. For the most part it works, I have been using it on my pi web server with most of my media, however the code didn’t have a way to list the playing track.

    How can I replace the TRACK NAME PLACEHOLDER text with the track that’s currently playing?

    Side note I only really know basic HTML and relatively no JavaScript...

    Code:
    <html>
    	<script type="text/javascript">
    		function loadPlayer()
    		{
    			var audioPlayer = new Audio();
    			audioPlayer.controls="controls";
    			audioPlayer.addEventListener('ended',nextSong,false);
    			audioPlayer.addEventListener('error',errorFallback,true);
    			document.getElementById("player").appendChild(audioPlayer);
    			nextSong();
    		}
    		function nextSong()
    		{
    			if(urls[next]!=undefined)
    			{
    				var audioPlayer = document.getElementsByTagName('audio')[0];
    				if(audioPlayer!=undefined)
    				{
    					audioPlayer.src=urls[next];
    					audioPlayer.load();
    					audioPlayer.play();
    					next++;
    				} 
    				else
    				{
    					loadPlayer();
    				}
    			}
    		}
    		function errorFallback()
    		{
    			alert('missing media!');
    			//nextSong();
    		}
    
    		function pickSong(num)
    		{
    			next = num;
    			nextSong();
    		}
    		var urls = new Array();
    			urls[0] = 'track_01.mp3';
    			urls[1] = 'track_02.mp3';
    			urls[2] = 'track_03.mp3';
    		var next = 0;
    	</script>
    	<body>
    		<table align="center" border="1" cellspacing="0" cellpadding="5" bgcolor="grey">
    			<tr>
    				<th colspan="2">Album Title</th>
    			</tr>
    			<tr>
    				<th colspan="2">TRACK NAME PLACEHOLDER</th>
    			</tr>
    			<tr>
    				<td colspan="2"><div id="player"></div></td>
    			</tr>
    			<tr>
    				<th colspan="2"><a href="#" onclick="nextSong()">Next / Skip</a></th>
    			</tr>
    			<tr>
    				<th><u>Track #</u></th>
    				<th><u>Name</u></th>
    			</tr>
    			<tr align="center">
    				<td>01</td>
    				<td><a href="#" onclick="pickSong(0)" style="text-decoration: none">Track A</a></td>
    			</tr>
    			<tr align="center">
    				<td>02</td>
    				<td><a href="#" onclick="pickSong(1)" style="text-decoration: none">Track B</a></td>
    			</tr>
    			<tr align="center">
    				<td>03</td>
    				<td><a href="#" onclick="pickSong(2)" style="text-decoration: none">Track C</a></td>
    			</tr>
    		</table>
    	</body>
    </html>

  2. #2
    thanks a lot
    I am the best writer http://www.Proessaywriting.com there i can help u=)

  3. #3
    Join Date
    Nov 2015
    Location
    New Delhi, India
    Posts
    12
    It's really useful. Thanks

  4. #4
    Join Date
    Dec 2016
    Posts
    0
    hih hgrggre
    essay writing service uk paper assistance don’t worry we are there to help you.

  5. #5
    Join Date
    Jan 2017
    Posts
    0
    Diseño web y diseño de paginas web profesionales en México DF CDMX Somos expertos en posicionamiento web, paginas optimizadas a celulares, precios bajos
    diseño de paginas web

  6. #6
    Join Date
    Jan 2017
    Posts
    0
    Sporttiv. 2,227 likes &#xb7; 2,656 talking about this. Sporttiv has the best Sports memes, NFL memes, NBA memes, Football memes and Soccer memes from all...
    Sporttiv

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •