简体   繁体   English

随机化HTML5视频海报图像

[英]Randomize HTML5 Video poster image

I've made a HTML5 video player and I'd like to force the poster image to show up for at least 4 seconds before the video plays. 我已经制作了HTML5视频播放器,我想强制海报图像在视频播放之前至少显示4秒钟。 I'd also like to randomize the images that show up. 我也想随机显示的图像。

I've tried to use PHP to look in side the images folder and randomize before image 1 to 3. However, I can't get the image to show up at all and I can't get it to randomize. 我尝试使用PHP在images文件夹中查找并在图像1至3之前进行随机化。但是,我根本无法显示图像,也无法将其随机化。 Can anyone help? 有人可以帮忙吗?

Here is my code: 这是我的代码:

<div class="vidWrap">

<video autoplay id="movingAlphaVid" style="display: none;"                                                                

preload="auto" poster="/images/image_<?php $random = rand(1,3); echo   $random; ?>.png" >

This code will work 该代码将起作用

<video autoplay id="movingAlphaVid" 
    controls="controls" src="your_video_file.ext" preload="auto"  
    poster="/images/image_<?php $random = rand(1,3); echo $random; ?>.png" >

Also check the video tag documentation at HTML Video Tag 另请参阅HTML Video Tag中video标签文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM