Hi there i am currently working on HTML5 Jquery video player. Here you can get more info about this HTML video player: http://www.videojs.com/docs/api/
From this link you can see that myPlayer.duration()
is the function that must show the video durration in seconds. And that's it i just want to display this value in simple HTML page like i am trying with my code.
This is my code:
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
</head>
<video id="vemvo-player" class="video-js vjs-default-skin" controls autoplay="true" width="950" height="534"
data-setup="{}">
<source src="[var.base_url]/uploads/[var.video_play]" type='video/flv' />
</video>
<div id="duration"></div>
<script type="text/javascript">
var myPlayer = _V_("vemvo-player");
_V_("vemvo-player").ready(function(){
var howLongIsThis = myPlayer.duration();
$('#duration').html('Duration: ' + howLongIsThis);
});
</script>
The problem with this code is that it's showing Duration: 0
when the video duration is far from 0.
My video player is working okey and it's showing durration of the video correctly. My question is how i can show this durration in HTML page value?
With the code above when i post var myPlayer = _V_("vemvo-player");
into _V_("vemvo-player").ready(function(){
function and i try in the console to run myPlayer.duration()
it gives me error for Undefined variable, but when var myPlayer = _V_("vemvo-player");
is outside the function like it is in my post and i type myPlayer.duration()
in the console it's giving me the durration in seconds like i need it.
The problem is that i can display this variable as a number in HTML page. I just want to display this number in HTML page.
Where is the mistake in my code and how i can fix it?
Thanks in advance!