CurrentTime textbox

http://stackoverflow.com/questions/18262145/passing-information-between-html-5-video-and-form-textarea

by TastyBytes

HTML

<video width="100%" controls id="video1">
  <source type="video/mp4" src="http://video-js.zencoder.com/oceans-clip.mp4">
</video>
<textarea id="text1" cols="20" rows="10"></textarea>

JavaScript

(function() {
    var theText = document.getElementById('text1');
    var theVideo = document.getElementById('video1');
    theText.addEventListener('focus', function(e) {
        curTime = theVideo.currentTime;
        curSecs = Math.floor((curTime % 60));
        
        curTimeText = "\n" + Math.floor( curTime / 60 ) + ":" + ((curSecs < 10)?'0'+curSecs:curSecs);
        
        theText.value = theText.value + curTimeText;
    });
})();