Source code of filesite.io. https://filesite.io
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.2 KiB

<?php
$videoUrl = '';
$poster = '';
$imgExts = ['jpg', 'jpeg', 'png', 'gif'];
$videoExts = ['mp4', 'm3u8'];
if (!empty($viewData['video'])) {
$video = $viewData['video'];
if (!empty($video['directory'])) { //如果是目录,则找出里面第一个mp4作为播放地址
$poster = $video['snapshot'];
if (!empty($video['files'])) {
foreach ($video['files'] as $id => $item) {
if (empty($poster) && in_array($item['extension'], $imgExts)) {
$poster = $item['path'];
}
if (in_array($item['extension'], $videoExts)) {
$videoUrl = $item['path'];
break;
}
}
}
}else {
$videoUrl = $video['path'];
}
}
?><div class="video">
<video class="video-js vjs-big-play-centered vjs-fluid vjs-16-9"
controls
playsinline
data-setup='{"autoplay":"muted"}'
poster="<?php echo !empty($viewData['video']['snapshot']) ? $viewData['video']['snapshot'] : ''; ?>"
id="myvideo">
<source src="<?php echo $videoUrl; ?>" type="video/mp4">
</video>
</div>