Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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/

share|improve this answer
    
Thanks a lot! Had completely forgotten about USER AGENTS! –  Samudra Jan 9 '12 at 6:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.