php解析js代码:php根据ios或安卓设置video.js宽度
php解析js代码:php根据ios或安卓设置video.js宽度if(strpos($agent 'iphone') || strpos($agent 'ipad'))//分别进行判断//全部变成小写字母$agent = strtolower($_SERVER['HTTP_USER_AGENT']);$type = 'other';
效果截图:
php代码:
function get_device_type()
{
//全部变成小写字母
$agent = strtolower($_SERVER['HTTP_USER_AGENT']);
$type = 'other';
//分别进行判断
if(strpos($agent 'iphone') || strpos($agent 'ipad'))
{
$type = 'ios';
}
if(strpos($agent 'android'))
{
$type = 'android';
}
return $type;
}
<video
style="object-fit:contain;background-color:#fff;"
id="my-video"
class="video-js"
controls
preload="auto"
<? if(get_device_type()=="android"){
?>
height="175"
<?
}elseif(get_device_type()=="ios"){
?>
height="205"
<?
}
?>
data-setup="{}"
poster = "<? echo $rowme["imagepath88"];?>"
>
<source src="<? echo $rowme["imagepath07"];?>" type="video/mp4" />
<p class="vjs-no-js">
To view this video please enable JavaScript and consider upgrading to a
web browser that
<a href="https://videojs.com/html5-video-support/" target="_blank"
>supports HTML5 video</a
>
</p>
</video>