Assuming there is a media(video) player on the web page.
On Flash,
<button name="test" onclick="alert(Math.floor(jwplayer().getPosition())+ 'secs elapsed!');">elapsed time</button>
This code shows elapsed time of the video
On HTML5,
<button name="test" onclick="alert(Math.floor(document.getElementById('video').currentTime) + 'secs elapsed!');">elapsed time</button>
This code also shows elapsed time of the video
I'm thinking of storing all the comments, and it's elapsed time into Database.
Then it automatically loads all comments of particular video when the user load the page.
And then it displays each comment as elapsed time goes by(My image is pop-up)
Is it possible with jQuery(or javascript)? If so how? Can anyone show me how to implement that easily.
if there is a comment like this
- At 5 secs "hello! 5 secs has past"
- At 20 secs "hello! 20 secs has past"
- At 35 secs "hello! 35 secs has past"
- At 35 secs "hello! 35 secs has past. part2"
- At 60 secs "hello! 35 secs has past"
UPDATE:
<!DOCTYPE html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>Test</title>
<script src="http://code.jquery.com/jquery-1.10.2.js" type="text/javascript"></script>
<meta name="keywords" content="">
<meta name="description" content="">
<script type="text/javascript">
jQuery(document).ready(function () {
var comments = [{'time':'5','message':'hello! 5 secs has past'},{'time':'10','message':'hello! 10 secs has past'},{'time':'30','message':'hello! 15 secs has past'}];
$('#video').on('timeupdate',function(e){
showComments(this.currentTime);
});
function showComments(time){
var comments = findComments(time);
$.each(comments,function(i,comment){
alert(comment.message);
});
}
function findComments(time){
return $.grep(comments, function(item){
return item.time == time.toFixed();
});
}
}
</script>
</head>
<body>
<video id='video'
controls preload='none'
poster="http://media.w3.org/2010/05/sintel/poster.png">
<source id='mp4'
src="http://media.w3.org/2010/05/sintel/trailer.mp4"
type='video/mp4'>
<source id='webm'
src="http://media.w3.org/2010/05/sintel/trailer.webm"
type='video/webm'>
<source id='ogv'
src="http://media.w3.org/2010/05/sintel/trailer.ogv"
type='video/ogg'>
<p>Your user agent does not support the HTML5 Video element.</p>
</video>
</body></html>