All pastes #1751049 Raw Edit

Unnamed

public text v1 · immutable
#1751049 ·published 2010-01-14 15:25 UTC
rendered paste body
<html>

    <video controls autoplay ></video>

    <script src=media-file.js></script>
    <script src=video-test.js></script>

    <script>
        var timeupdateEventCount = 0;
    
        testExpected("video.getAttribute('loop')", null);
        testExpected("video.loop", false);
    
        run("video.loop = true");
        testExpected("video.loop", true);
        testExpected("video.getAttribute('loop')", null, "!=");
    
        run("video.removeAttribute('loop')");
        testExpected("video.loop", false);
    
        var firstTimeCheck = true;

        waitForEvent('pause');
        waitForEvent('play');

        function timeupdate()
        {
            ++timeupdateEventCount;

            // wait 2 timeupdate events so we are sure the media engine is
            // playing the media.
            if (timeupdateEventCount == 2) {
               // make sure we are playing, seek to near the end so
               // the test doesn't take too long
               testExpected("video.paused", false);
               run("video.currentTime = video.duration - 0.4");
               consoleWrite("");
            } else if (timeupdateEventCount >= 10) {
               if (firstTimeCheck) {
                  consoleWrite("EVENT(playing)");
                  testExpected("video.ended", false);
                  testExpected("mediaElement.currentTime", 0, '>');
                  testExpected("mediaElement.currentTime", (video.duration - 0.4).toFixed(2), '<');
                  run("video.loop = false");
                  run("video.currentTime = video.duration - 0.3");
                  consoleWrite("");
                  firstTimeCheck = false;
               }
            }
        }

        function ended() {
            testExpected("video.ended", true);
            // don't use "testExpected()" so we won't log the actual duration to the
            //  results file, as the floating point result may differ with different engines
            reportExpected(mediaElement.currentTime == mediaElement.duration, "mediaElement.currentTime", "==", "mediaElement.duration", mediaElement.currentTime);
            endTest();
            consoleWrite("");
        }

        consoleWrite("");
        run("video.loop = true");
        var mediaFile = findMediaFile("video", "content/test");
        run("video.src = '" + mediaFile + "'");
        mediaElement.addEventListener("timeupdate", timeupdate);
        mediaElement.addEventListener("ended", ended);
        consoleWrite("");
    </script>

    </head>

</html>