0

我有一个简单的 HTML5 视频播放器

<video width="100%" controls="controls">
    <source src="" type="" />
</video>

和一个在页面上带有 textarea 的简单表单。为了让我的客户更容易对我的视频提供反馈,我想做一些事情:

  • 如果用户在 textarea 中,当他们开始输入时,我想自动暂停视频并将视频中的当前时间码插入到 textarea 中,然后在他们按 Enter 换行时恢复视频。(如果可能,这个功能应该有一个开/关按钮。)

  • 我还想在文本区域上方有一个按钮,允许他们将视频当前时间码插入文本区域(在所有当前文本的末尾)。

这可能吗?

非常感谢您的帮助。

4

1 回答 1

1

这个小提琴应该让你朝着正确的方向前进。 http://jsfiddle.net/3n1gm4/kLWL4/

JS:

(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;
    });
})();

HTML:

<video width="100%" controls id="video1">
  <source type="video/mp4" src="">
</video>
<textarea id="text1" cols="20" rows="10"></textarea>
于 2013-08-15T21:46:06.257 回答