HTML5视频背景无法加载

时间:2014-05-18 02:04:15

标签: php css html5 html5-video

Newb在这里再次尝试超出他们技能的东西,以扩展技能组合。

我试图将循环视频播放作为我的小形式的背景(newb尝试新的东西作为学习练习)。一切似乎都加载,链接/路径正确,文件上传到他们的文件夹等。我已经找了拼写错误并检查了我的括号,冒号和分号等。我已经到了可以,但我并不完全'那里'但视频并没有像希望的那样播放。

protosite example here

    <?php

# '../' == sub-folder.  use './' == root
require '../inc_0700/config_inc.php'; #provides configuration, pathing, error handling, db credentials

echo "
    <style>
    body {text-align: center;}
    p {color: #aaa;}

    #bgImg{
        position: absolute;
        top: 0;
        left: 0;
        border: 0;
        z-index: 1;
        width: 100%;
        height: 100%;
    }

    #bgVideo{
        position: absolute;
        top: 0;
        left: 0;
        border: 0;
        z-index: 2;
        width: 100%;
        height: 100%;
    }

    #bodyDummy{
        position: absolute;
        top: 0;
        left: 0;
        z-index: 3;
        overflow: auto;
        width: 100%;
        height: 100%;
    }



    form {
    /*background: -webkit-gradient(linear, bottom, left 175px, from(#CCCCCC), to(#EEEEEE));
        background: -moz-linear-gradient(bottom, #CCCCCC, #EEEEEE 175px);*/

        background: url(img_black-opacity80.png) 0 0 repeat;

        background-color: transparent;
        margin:auto;
        position:relative;
        width:550px;
        min-height:450px;

        /*font-family: Tahoma, Geneva, sans-serif;
        font-size: 14px;
        font-style: italic;
        line-height: 24px;
        font-weight: bold;
        color: #09C;
        */

        text-decoration: none;
        -webkit-border-radius: 6px;
        -moz-border-radius: 6px;
        border-radius: 6px;
        padding:10px;
        border: 2px solid #ff6d26;
        border: inset 1px solid #333;
        -webkit-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
        -moz-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
        box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
        }

        form b a#orange {color: #ff6d26; text-decoration: underline;}
        form b a#orange:hover {color: white;}

        input, select, textarea{ color: #aaa;}
        textarea:focus, input:focus {color: #c66f3f;}


        input{border: 1px solid #ff6d26;
            width:375px;

            margin-top: 10px;
            background-color: #222329;
            min-height: 25px;
            padding: 5px 0px 5px 5px;

            -webkit-box-shadow:
            inset 0 0 4px  rgba(0,0,0,0.1),
                    0 0 46px rgba(0,0,0,0.1);
            -moz-box-shadow:
              inset 0 0 4px  rgba(0,0,0,0.1),
                    0 0 4px rgba(0,0,0,0.1);
            box-shadow:
              inset 0 0 4px  rgba(0,0,0,0.1),
                    0 0 4px rgba(0,0,0,0.1);
        }
        h2 {color: #ff6d26;}
        b {color: #ff6d26;}

        #go {width:50; color:#ddd; background-color: #ff6d26;}

        footer{bottom:0;}


    </style>
    ";
//END CONFIG AREA ----------------------------------------------------------

# Read the value of 'action' whether it is passed via $_POST or $_GET with $_REQUEST
if(isset($_REQUEST['act'])){$myAction = (trim($_REQUEST['act']));}else{$myAction = "";}

switch ($myAction){//check 'act' for type of process
    case "display": # 2)Display user's name!
        showObjects();
        break;

    case "clear": # 3 Clear the session data
        clearObjects();
        showForm();
        break;

    default: # 1)Ask user to enter their name
         showForm();
}

function showForm(){# shows form so user can enter their name.  Initial scenario
    get_header(); #defaults to header_inc.php

    echo
    '<script type="text/javascript" src="' . VIRTUAL_PATH . 'include/util.js"></script>
    <script type="text/javascript">
        function checkForm(thisForm){//check form data for valid info
            if(empty(thisForm.YourName,"Please Enter Your Name")){return false;}
            return true;//if all is passed, submit!
        }

    </script>


<video id="bgVideo" autoplay poster="_bgGrfxs/bg_vidGlobe.jpg">
    <source src="_bgVideo/bg_vidLoop.mp4" type="_bgVideo/mp4"/>
    <!--<source src="_bgVideo/bg_vidLoop.webm" type="_bgVideo/webm"/>-->
    <source src="_bgVideo/bg_vidLoop.ogv" type="_bgVideo/ogg"/>
</video>

<img id="bgImg" src="_bgGrfxs/bg_vidGlobe.jpg" />

<!-- This image stretches exactly to the browser width/height and lies behind the video-->

<div id="bodyDummy">
    <!-- <h3 align="center"">' . smartTitle() . '</h3>-->
    <br />
    <br />
    <br />


    <form align="center" action="' . THIS_PAGE . '" method="post" onsubmit="return checkForm(this);">
        <img width="20%" src="img_logo-panPacificDefenseCenter.png" alt="Kaiju Incident Reporter"/>

        <br />
            <h2 style="color: #ff6d26;">Incident Report Form</h2>
        <br />

        <!-- incWho? -->
        <br />
            <b>Reporting Officer ID:</b><br />
            <input type="text" name="incWho" placeholder="Please enter your full name here" />
        <br />
        <br />


        <!-- incWhat -->
            <b><a id="orange" href="http://godzilla.wikia.com/wiki/Main_Page">Massive Unidentified Terrestrial Organism encountered:</a></b><br />
                <select
                    type="text"
                    name="incWhat"
                    data-placeholder="Select Incident Location..."
                    class="chzn-select"
                    multiple style="width:354px;"
                    tabindex="40">
                ';

            include 'ddlist-Kaiju.php';
        echo '</select>
        <br />
        <br />


        <!-- incWhen = date of incident -->
            <b>Date of Incident:</b><br />
            <input type="text" name="incWhen" placeholder="Please enter your full name here" />
        <br />
        <br />


        <!-- incWhere -->
            <b>Incident Location:</b><br />
                <select
                    type="text"
                    name="incWhere"
                    data-placeholder="Select Incident Location..."

                    multiple style="width:354px;"
                    tabindex="111">
                ';

            include 'ddlist-countriesInternational.php';
        echo '</select>

            <br />
            <br />


        <!-- incWhy -->
                <b>Incident notes:</b><br />
                <textarea name="incWhy"
                    cols="54" rows="5"
                    placeholder="Please enter any details you can recall of the incident - if incident is still occurring run" ></textarea>
            <br />
            <br />


        <!-- incScale -->
           <b>Rate the severity of the incident (0 to 5):</b>
            <br />
            <br />
           <input type="range"
            data-show-value="true"
            data-hightlight="true"
            data-popup-enabled="true"
            name="incScale" min="0" max="5" value="0" onchange="updateTextInput(this.value);">
            <br />
            <br />

           <input id="go" type="submit" value="Go!">

            </p>
        <input type="hidden" name="act" value="display" />
    </form>
    <br /><p style="#444"><i>Once you have completed your incident report, Run! For the love god man run, run for the hills and be safe!</i></p>
    ';
    get_footer(); #defaults to footer_inc.php

    echo '</div><!-- END bodyDummy -->';
}

function showObjects()
{#form submits here we show entered name
    //dumpDie($_POST);

    //if the session is not started, that could be a problem
    get_header(); #defaults to footer_inc.php
    if(!isset($_SESSION)){session_start();}

    echo "<br />";

    if(!isset($_SESSION['kSession']))
    {//if no session exists, create it
    $_SESSION['kSession']= array();
    }

    //we need to add post data here
    $_SESSION['kSession'] [] = new incReport($_POST['incWho'], $_POST['incWhat'], $_POST['incWhen'], $_POST['incWhere'], $_POST['incWhy'], $_POST['incScale']);

    $totalScale = 0;
    foreach($_SESSION['kSession'] as $incReport)//loop thru each array item
    {
        echo $incReport;
        $totalScale += $incReport->incScale;
    }

    $totalReports = count($_SESSION['kSession']);
    $aveRating = $totalScale/$totalReports;
        echo "<div style=\"margin: auto; padding:0 10px; background-color:#ff6d26;width: 300px\";><p style=\"color:white;\">Average Incident Severity:</p> <h1 style=\"color:white;\";>$aveRating</h1></div>";
        if ($aveRating == 5){ echo "Five: We suggest you make peace with this, your final moment.. enjoy the sunset before that giant foot comes down on you.</p></form>";}
        if ($aveRating == 4){ echo "Four: The end is near, run man run, she isn't worth it, save yourself.</p></form>";}
        if ($aveRating == 3){ echo "Three: And your still there? Seriously?</p></form>";}
        if ($aveRating == 2){ echo "Two: Take a picture, it will last longer. Now. Run for the hills!</p></form>";}
        if ($aveRating == 1){ echo "One: Have you considered running?</p>";}
        if ($aveRating == 0){ echo "Zero: This would be a good time to consider moving to a safer vantage point.</p></form>";}



        //get_footer(); #defaults to footer_inc.php

    //------end of work area-------//

    get_header(); #defaults to footer_inc.php
    if(!isset($_POST['incWho']) || $_POST['incWhat'] == ''){//data must be sent
        feedback("No form data submitted"); #will feedback to submitting page via session variable
        myRedirect(THIS_PAGE);
    }

    if(preg_match('[^A-Za-z0-9]', $_POST['incWho'])){//data must be alphanumeric only
        feedback("Only letters &amp; numbers are allowed."); #will feedback to submitting page via session variable
        myRedirect(THIS_PAGE);
    }

    $myName = strip_tags($_POST['incWho']);# here's where we can strip out unwanted data
    echo '<p align="center"><a href="' . THIS_PAGE . '">File Report, then Run!</a> | <a href="' . THIS_PAGE . '?act=clear">Reset</a></p>';
    }


    function clearObjects(){
        //echo "clearing objects here";
        if(!isset($_SESSION)){session_start();}
        unset($_SESSION['kSession']);
        feedback("session cleared");
    }

    class incReport{
        public $incWho = "";
        public $incWhat = "";
        public $incWhen = "";
        public $incWhere = "";
        public $incWhy = "";
        public $incScale = "";


        function __construct($incWho, $incWhat, $incWhen, $incWhere, $incWhy, $incScale){
            $this->incWho=$incWho;
            $this->incWhat=$incWhat;
            $this->incWhen=$incWhen;
            $this->incWhere=$incWhere;
            $this->incWhy=$incWhy;
            $this->incScale=$incScale;
        }


    function __toString(){
    static $kID = 1;//kaiju incident number

        $myReturn = "<form><p> Incident ID: kID00" . $kID ; //works
        $kID++; //iterate report

        $myReturn .= " | Incident Reported by: " . $this->incWho . "   " ;//works

        $myReturn .= " | Massive Terrestial Organsim Observed: " . $this->incWhat . "   " ;//shows where...
        $myReturn .= " | Date of Incident: " . $this->incWhen . "   " ; //works
        $myReturn .= " | Incident Location: " . $this->incWhere . " "; //shows what
        $myReturn .= " | Incident Details: " . $this->incWhy. " "; // working
        $myReturn .= " | Incident Severity: " . $this->incScale . "</p>" ;

        return $myReturn;
    }
}

1 个答案:

答案 0 :(得分:1)

源标记上的type属性不正确,应该是

<source src="_bgVideo/bg_vidLoop.mp4" type="video/mp4"/>
<source src="_bgVideo/bg_vidLoop.ogv" type="video/ogg"/>

http://jsfiddle.net/eN2M6/