Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
119
rated 0 times [  126] [ 7]  / answers: 1 / hits: 22880  / 8 Years ago, thu, may 5, 2016, 12:00:00

I am using Chrome. In my dev tools console, I tried the following:



enter



Everything works as expected except last line. Why can't I set currentTime on it?



Also in general, I am finding this whole HTML5 Audio thing to not be very reliable. Is there a robust javascript wrapper that fallsback to flash ?


More From » html

 Answers
1

You need to do something like this (if you use jQuery)



$('#elem_audio').bind('canplay', function() {
this.currentTime = 10;
});


or in Javascript



var aud = document.getElementById(elem_audio);
aud.oncanplay = function() {
aud.currentTime = 10;
};


The reason behind for this setup is you need to make sure the audio is ready to play.


[#62298] Tuesday, May 3, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
harleedayanarar

Total Points: 303
Total Questions: 90
Total Answers: 102

Location: Virgin Islands (U.S.)
Member since Tue, Jul 7, 2020
4 Years ago
;