如何显示闪存可用的SWF,并优雅地回退到iOS设备的MP4视频?

时间:2012-01-05 作者:Samudra

我有一个SWF,它使用MP4文件作为视频部分(SWF还有一个目录,这对我来说很重要)。但当在iOS设备上查看网站时(或在没有flash的地方),我希望播放MP4文件(使用jwplayer等)

我如何实现这一点?有处理SWF和MP4的Wordpress插件吗?

1 个回复
最合适的回答,由SO网友:krembo99 整理而成

您可以通过多种方式实现这一点,PHP、纯Javascript、Jquery。。。取决于主题/应用程序中的许多其他变量。我可以列出所有方法的利弊,但这不是正确的地方。。

例如,在php中,您可以直接在用户代理上或通过get\\u browser()使用浏览器检测。

简单示例:

if(strstr($_SERVER[\'HTTP_USER_AGENT\'],\'iPod\') || strstr($_SERVER[\'HTTP_USER_AGENT\'],\'iPhone\'))
{
    // LINK TO NORMAL 
}else {
            //were not - put SWF
    }
iOs一起:

$iPod = stripos($_SERVER[\'HTTP_USER_AGENT\'],"iPod");
$iPhone = stripos($_SERVER[\'HTTP_USER_AGENT\'],"iPhone");
$iPad = stripos($_SERVER[\'HTTP_USER_AGENT\'],"iPad");

if( $iPod || $iPhone || $iPad ){
        //were an iPhone/iPod touch/iPad -- Load normal link 
}else {
        //were not - put SWF
}
?>  
移动设备的全面检测:

//Detect special conditions devices

$iPod = stripos($_SERVER[\'HTTP_USER_AGENT\'],"iPod");
$iPhone = stripos($_SERVER[\'HTTP_USER_AGENT\'],"iPhone");
$iPad = stripos($_SERVER[\'HTTP_USER_AGENT\'],"iPad");
if(stripos($_SERVER[\'HTTP_USER_AGENT\'],"Android") && stripos($_SERVER[\'HTTP_USER_AGENT\'],"mobile")){
        $Android = true;
}else if(stripos($_SERVER[\'HTTP_USER_AGENT\'],"Android")){
        $Android = false;
        $AndroidTablet = true;
}else{
        $Android = false;
        $AndroidTablet = false;
}
$webOS = stripos($_SERVER[\'HTTP_USER_AGENT\'],"webOS");
$BlackBerry = stripos($_SERVER[\'HTTP_USER_AGENT\'],"BlackBerry");
$RimTablet= stripos($_SERVER[\'HTTP_USER_AGENT\'],"RIM Tablet");
//do something with this information
if( $iPod || $iPhone ){
        //were an iPhone/iPod touch -- do something here
}else if($iPad){
        //were an iPad -- do something here
}else if($Android){
        //were an Android Phone -- do something here
}else if($AndroidTablet){
        //were an Android Phone -- do something here
}else if($webOS){
        //were a webOS device -- do something here
}else if($BlackBerry){
        //were a BlackBerry phone -- do something here
}else if($RimTablet){
        //were a RIM/BlackBerry Tablet -- do something here
}
此代码来自http://www.schiffner.com/index.php/programming-php-classes/php-mobile-device-detection/

您也可以在此处进行全体重训练:

http://chrisschuld.com/projects/browser-php-detecting-a-users-browser-from-php/

结束