0

I'm using WordPress shortcodes outside the installation folder (specifically the video shortcode) to play locally hosted videos, but I have a problem with IE.

The videos are loading fine with HTML5 on all major browsers and even with Firefox when using only Flash, but when testing with Flash on IE I see nothing even though the page is loading the code.

mediaelement's fallback works fine when accesing a WordPress page directly with a video embedded in it, but on my php page outside the install folder it just doesn't work.

Here's my code:

<?php 
    define('WP_USE_THEMES', false);
    require('../wp-load.php');

    echo '<link rel="stylesheet" type="text/css" href="../wp-includes/js/mediaelement/mediaelementplayer.min.css" />';
    echo '<link rel="stylesheet" type="text/css" href="../wp-includes/js/mediaelement/wp-mediaelement.css" />';
    echo '<link rel="stylesheet" type="text/css" href="sample.css" />';

    echo '<script src="../wp-includes/js/jquery/jquery.js"></script>';
    echo '<script src="../wp-includes/js/mediaelement/mediaelement-and-player.min.js"></script>';
    echo '<script src="../wp-includes/js/mediaelement/wp-mediaelement.js"></script>';

    echo do_shortcode('[video src="//leandroperez.com.ar/sample/08-2014_002.mp4" width="640" height="360" autoplay="true" loop="true"]');
?>

Any ideas?

0

I figured out the issue. I'm leaving the answer for future reference.

Turns out IE needs you to include all the HTML tags for the video to load correctly when using flash. This is my working code now:

<?php 
    define('WP_USE_THEMES', false);
    require('../wp-load.php');

    echo '<!doctype html>';
    echo '<html>';
    echo '<head>';
    echo '<meta charset="utf-8">';
    echo '<title></title>';

    echo '<link rel="stylesheet" type="text/css" href="../wp-includes/js/mediaelement/mediaelementplayer.min.css" />';
    echo '<link rel="stylesheet" type="text/css" href="../wp-includes/js/mediaelement/wp-mediaelement.css" />';
    echo '<link rel="stylesheet" type="text/css" href="sample.css" />';

    echo '<script src="../wp-includes/js/jquery/jquery.js"></script>';
    echo '<script src="../wp-includes/js/mediaelement/mediaelement-and-player.min.js"></script>';
    echo '<script src="../wp-includes/js/mediaelement/wp-mediaelement.js"></script>';
    echo '</head>';

    echo '<body>';
    echo do_shortcode('[video src="//leandroperez.com.ar/sample/08-2014_002.mp4" width="640" height="360" autoplay="true" loop="true" preload="auto"]');
    echo '</body>';
    echo '</html>';
?>

Not sure if this is the best way to add HTML to a PHP, but it's working.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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