【发布时间】:2017-04-15 15:51:01
【问题描述】:
我正在使用视频 html5 元素来获取持续时间属性以查找最后一次 当用户关闭浏览器或用户暂停时视频停止播放的位置,将其发送到数据库,以便稍后从停止的位置继续播放。
目前我用谷歌搜索并检查堆栈溢出是这样的
<script type="text/javascript">
$("#video").on("durationchange", function() {
alert("Current duration is: " + this.duration);
});
</script>
<video id="video" poster="image.jpg" controls>
<source src="video_path.mp4" type="video/mp4" />
</video>
我还想寻找视频到用户登录后停止的持续时间 到我的应用程序。我试过了,但不是正确的做法
$(window).load(function() {
.ajax({
type: "GET",
url: "/api/videoResume/",
data: param = "",
contentType: "application/json; charset=utf-8",
dataType: "json"
})
.done(function(result){
//update the video element duration
//seeking video to the duration
})
});
【问题讨论】:
-
window.onbeforeunload = video.onpause = e => postToYourServer(video.currentTime)
标签: javascript jquery html html5-video