html poster 属性允许用户在单击播放按钮或下载视频时显示图像。否则,如果没有设置海报属性,将使用视频的第一帧作为海报图片。
语法以下是 html 属性的语法。
<video poster=url>
让我们深入研究以下示例,您可以在其中了解有关 html 属性的更多信息。
示例 1在以下示例中,我们使用 元素和海报属性。
<!doctype html><html><body> <center> <video width=340 height=220 controls poster=https://www.tutorialspoint.com/static/images/logo-color.png> <source src=https://samplelib.com/lib/preview/mp4/sample-5s.mp4 type=video/mp4> </video> </center></body></html>
执行上述脚本时,它将生成一个输出,其中包含上传的视频以及使用 海报属性作为海报添加到视频中的图像。
示例 2考虑以下示例,其中我们使用两个视频,其中一个带有 属性。
<!doctype html><html><body> <center> <video width=340 height=220 controls poster=https://www.tutorialspoint.com/images/logo.png> <source src=https://samplelib.com/lib/preview/mp4/sample-5s.mp4> </video> <video width=320 height=240 controls> <source src=https://samplelib.com/lib/preview/mp4/sample-30s.mp4> </video> </center></body></html>
当脚本执行时,它会生成一个由上传到网页的两个视频组成的输出,其中一个添加了 html 属性,另一个是正常的。
以上就是在html中,我们如何设置在视频下载时显示图像?的详细内容。
