您的位置 首页 php

开发技巧:php根据ios或安卓设置video.js宽度

效果截图:

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 = “<?%20echo%20$rowme[“imagepath88″];?>”

>

<source src=”<?%20echo%20$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=”#34;%20target=”_blank”

>supports HTML5 video</a

>

</p>

</video>

文章来源:智云一二三科技

文章标题:开发技巧:php根据ios或安卓设置video.js宽度

文章地址:https://www.zhihuclub.com/78413.shtml

关于作者: 智云科技

热门文章

网站地图