单击按钮时如何将视频的时间戳保存到sql数据库

时间:2019-06-26 07:54:16

标签: javascript html video video-streaming

使用此代码播放视频文件并动态显示其时间戳。

现在我想要的是有一个按钮,当单击该按钮时,它会检索当前的视频时间戳,这样我就可以将其保存到一个名为(ts)列的sql表(名为tstamp)

<title>VIDEO PLAY</title>

<script src="http://vjs.zencdn.net/4.6.1/video.js"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"/>

<body>

    <h1>VIDEO  PLAY</h1>

    <video id="my_video_1" class="video-js vjs-default-skin" controls preload="auto" width="640" height="268"
      data-setup='{ "playbackRates": [0.5, 1, 1.5, 2, 4] }'>
        <source src="movie.m4v" type='video/mp4' />
        <track src='br.srt' kind="subtitles" srclang="en" label="English" default />
    </video>

    <p>TimeStamp: <span id="demo"></span></p>
    <script>
    // Get the audio element with id="my_video_1"
    var aud = document.getElementById("my_video_1");

    // Assign an ontimeupdate event to the audio element, and execute a function if the current playback position has changed
    aud.ontimeupdate = function() {myFunction()};

    function myFunction() {
      // Display the current position of the audio in a p element with id="demo"
      document.getElementById("demo").innerHTML = aud.currentTime;
    }
    </script>


</body>

0 个答案:

没有答案