My problem is simple:
I have the next HTML5 video:
<div class="video_container">
<video id="home_explainer_placeholder" class="video_placeholder" poster="/static/images/white_background.jpg">
<source src="/static/videos/zapyo_intro.mp4" type="video/mp4">
</video>
<div>Current Time : <span id="currentTime">0</span></div>
<div>Total time : <span id="totalTime">0</span></div>
<div id="home_explainer_overlay" class="placeholder_overlay">
<div class="video_overlay">
<div class="play_control">
<div class="play_button"></div>
<span class="gray">Click for video</span>
</div>
<div class="controls">
<div class="video_mute off"></div>
<div class="video_mute on"></div>
<div class="video_fullscreen"></div>
<div class="video_play"></div>
<div class="video_pause"></div>
</div>
</div>
</div>
</div>
I would like to get a backwards timer in JS which will start after I press the play button and stop if somebody presses on pause.
I have tried to do something like this in JavaScript but when I press on my play button, nothing happens ( more, the video do not work ):
$(function(){
$('#currentTime').html($('#home_explainer_overlay').find('video').get(0).load());
$('#currentTime').html($('#home_explainer_overlay').find('video').get(0).play());
})
setInterval(function(){
$('#currentTime').html($('#home_explainer_overlay').find('video').get(0).currentTime);
$('#totalTime').html($('#home_explainer_overlay').find('video').get(0).duration);
},500)
The HTML for that JS:
<div>Current Time : <span id="currentTime">0</span></div>
<div>Total time : <span id="totalTime">0</span></div>
Any hints on how would I achieve this ? I want to mention that I don't have a solid JS background so please explain me any solution you come with.
I have verified other simillar questions from so, but nothing worked in my case.