MP4 video cannot play on iPad/iPod/iPhone using JW Player shortcode

It seems that this is a bug on JW Player for WordPress plugin
We added JW Player or WordPress plugin shortcode with a mp4 video in it, the video plays on Macbooks and PCs, but it shows blank on iPad or iPod or iPhone.
Although HTML5 as default mode, it doesn’t work.

How to fix that?
1. Browse Media subfolder, find it inside wp-content/plugins/jw-player-plugin-for-wordpress
1. Open JWShortcode.php with PHP/Text Editor
2. Find function generate_embed_code($atts) in line no 233 – 265
3. Replace the function code with following

function generate_embed_code($atts) {
  $version = version_compare(get_option(LONGTAIL_KEY . "version"), "5.3", ">=");
  $embedder = file_exists(LongTailFramework::getEmbedderPath());
  if (preg_match("/iP(od|hone|ad)/i", $_SERVER["HTTP_USER_AGENT"])) {
    $loaded_config = LongTailFramework::getConfigValues();
    $width = isset($atts["width"]) ? $atts["width"] : $loaded_config["width"];
    $height = isset($atts["height"]) ? $atts["height"] : $loaded_config["height"];
    $output = '<video src="' . $atts["file"] . '" width="' . $width . '" height="' . $height . '" controls="controls"></video>';
    return $output;
  } else {
  if (!$embedder && !$version) {
    $youtube_pattern = "/youtube.com\/watch\?v=([0-9a-zA-Z_-]*)/i";
    $loaded_config = LongTailFramework::getConfigValues();
    $width = isset($atts["width"]) ? $atts["width"] : $loaded_config["width"];
    $height = isset($atts["height"]) ? $atts["height"] : $loaded_config["height"];
    $output = "";
    if (preg_match($youtube_pattern, $atts["file"], $match)) {
      $output = '<object width="' . $width . '" height="' . $height . '"><param name="movie" value="http://www.youtube.com/v/' . $match[1] . '&amp;hl=en_US&amp;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' . $match[1] . '&amp;hl=en_US&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' . $width . '" height="' . $height . '"></embed></object>';
    } 
    return $output;
  } else {
    if (get_option(LONGTAIL_KEY . "player_location_enable")) {
      $swf = LongTailFramework::generateSWFObject($atts, $embedder, get_option(LONGTAIL_KEY . "player_location"));
    } else {
      $swf = LongTailFramework::generateSWFObject($atts, $embedder);
    }
    if (!get_option(LONGTAIL_KEY . "use_head_js")) {
      insert_embedder($embedder);
    }
    return $swf->generateEmbedScript();
  }
  }
}

Comments

3 responses to “MP4 video cannot play on iPad/iPod/iPhone using JW Player shortcode”

  1. i like to try if this will help for my needs. 
    cause with Firefox 3.6.28 & Camino 2.1.2 there is something nearly equal, mp4 Video gets loaded, it plays, the sound is to be heard but no picture appears. maybe it belongs to my old fashioned flash-plugin on my old ppc mac? 
    Although the video is played best on my android (2.3.7) -browser – but a iPhone etc. i don´t have …thx anyway!

    1. If you are tying to play mp4 files and you are having problem with it (video not playing before it fully loaded) you must swap the index of the mp4 files using this app http://renaun.com/blog/code/qtindexswapper/

      1. thx Katelyn!
        but this app will not work on my system.;-(
        otherwise – i did allready change and do use now these flash-videos instead of mp4

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: