我试图在播放之前预先加载整个内容,因为我无法将视频停止,缓冲并继续.是否有一个我可以收听的事件,表示在开始播放之前整个视频已预先加载?
这是我在JS / jQuery中的表现:
this.canvas = this.el.find("canvas")[0]; this.video = this.el.find("video")[0]; this.ctx = this.canvas.getContext("2d"); this.video.autoplay = false; this.video.addEventListener("play",this.draw) this.video.addEventListener("timeupdate",this.draw) this.video.addeventlistener("ended",this.trigger("complete",this))
解决方法
从Opera团队出色(虽然现在可能非常过时)资源Everything you need to know about HTML5 video and audio
If the load is successful,whether using the src attribute or using source elements,then as data is being downloaded,progress events are fired. When enough data has been loaded to determine the video’s dimensions and duration,a
loadedMetadata
event is fired. When enough data has been loaded to render a frame,theloadeddata
event is fired. When enugh data has been loaded to be able to play a little bit of the video,acanplay
event is fired. When the browser determines that it can play through the whole video without stopping for downloading more data,acanplaythrough
event is fired; this is also when the video starts playing if it has a autoplay attribute.
请注意,iOS设备不支持“canplaythrough”事件,如areweplayingyet.org:http://areweplayingyet.org/event-canplaythrough所述
原文地址:https://www.jb51.cc/html5/168553.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。