filesite
2 years ago
4 changed files with 74 additions and 19 deletions
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
<?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> |
Loading…
Reference in new issue