Hi all website development experts,
I am a newbie to website design.
I am 13 years old but my passion is to record my own music from the different instruments I play and I love singing as well.
I am trying to make my own online Music Library so that people can listen to some of my songs in full for free or listen to a preview of my songs and buy them online.
I have created an Album Web Page which displays all the songs I have uploaded to my ISP's Web Server.
I have either a Free Play or Preview Button listed for each song in the Album.
If the users click on this Image Button, I want it to change onclick to a Pause Button.
If the users then click on the Pause Image Button I want it to change back to the Free Play or Preview Button.
I also want the Song to continue to play from where the user clicked on the Pause Button until either the end of the song or the end of the preview length of 15 seconds for the song, if it is available as a Preview Song.
What is the easiest way to achieve this.
I have the following code so far:
Javascript:
<script>
function play(id){
var audio = document.getElementById('audio'+id);
audio.play();
}
function pause(id){
var audio = document.getElementById('audio'+id);
audio.pause();
}
function changSRC() {
document.getElementById("imageid").src="/images/Song_Pause.png";
}
</script>
HTML:
<html>
<body>
<audio id="audio1">
<source src="/songs/Hall-of-the-Mountain-King.mp3" type="audio/mpeg">
<source src="/songs/Hall-of-the-Mountain-King.ogg" type="audio/ogg">
</audio>
<a href="javascript:play('1');"><img src="/images/Free_Play.png" align="center" width="100%" alt="Free Play" onclick="changSRC()" /></a>
<audio id="audio2">
<source src="/songs/Rimsky-Korsakov-The-Flight-of-the-Bumble-Bee.mp3#t=0,15" type="audio/mpeg">
<source src="/songs/Rimsky-Korsakov-The-Flight-of-the-Bumble-Bee.ogg#t=0,15" type="audio/ogg">
</audio>
<a href="javascript:play('2');"><img src="/images/Preview.png" align="center" width="100%" alt="Song Preview" onclick="changSRC()" /></a>
</body>
</html>
Now I am stuck.
How do I continue on from here to get the Songs to play again from when the user clicked on the Pause Button from the point they clicked on the Pause Button until the end of the 15 second preview or until the end of the song for the Free Play songs.
I will really appreciate any help. Thank you so much in advance!
Kind Regards,
Nancy