How to show SWF, where Flash is available, and gracefully fallback to MP4 video for iOS devices?

I have a SWF, which uses a MP4 file for the video part (the SWF also has a Table of Contents, which is important for me to have). But when viewing the website on iOS devices, (or where there is no flash), I would like the MP4 file to be played (using jwplayer, etc)

How can I implement this? Is there a Wordpress plugin which handles SWF as well as MP4?

Topic video-player jwplayer flash Wordpress

Category Web


you can achieve that in many ways, PHP, plain Javascript, Jquery...depending on many other variables in your theme / app. I could list pros and cons for all methods , but it is not the right place ..

In php for example, you could use browser detection both directly on user agent OR with get_browser() .

simple example :

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

iOs together :

$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
}
?>  

full detection for mobile :

//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
}

this code is from http://www.schiffner.com/index.php/programming-php-classes/php-mobile-device-detection/

you can also a FULL weight class here :

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

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.