WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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'))
}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;
        $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 :


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

Your Answer


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.