Does anyone know how to set the currentTime property of html5 audio by clicking a link with a time? Similar to how Youtube does it? Say I click a link "3:10", it will instantly change the currently playing audio's currentTime to 3:10.
I'm mainly just having difficulty obtaining the time from the link. I only want to have one function covering all time links, obviously I don't want to have this:Code:<audio controls loop class="sound"> <source src="../../site/music/music1.mp3"/> <source src="../../site/music/music2.ogg"/> </audio> Lorem ipsum dolor sit amet, <b><a>3:10</a></b> consectetur adipiscing elit <b><a>4:10</a></b>.
Instead I need to fetch the time from the link like this:Code:$('.3_10').on('click', function(e){ //set time to 3:10 }); $('.3_15').on('click', function(e){ //set time to 3:15 }); $('.3_17').on('click', function(e){ //set time to 3:17 }); $('.4_10').on('click', function(e){ //set time to 4:10 });
Code:$('.timelink').on('click', function(e){ //get the time from the link //set currentTime to target time });
Thanks.



Reply With Quote
Bookmarks