111 lines
4.0 KiB
HTML
111 lines
4.0 KiB
HTML
<html>
|
|
<head>
|
|
<title>Test of 'played' attribute</title>
|
|
<script src=media-file.js></script>
|
|
<script src=video-test.js></script>
|
|
<script src=video-played.js></script>
|
|
<script>
|
|
|
|
var testFunctions =
|
|
[
|
|
PlayWithNoRanges,
|
|
CreateANewRange,
|
|
JumpAndCollapseTwoRanges,
|
|
TestLoopingAndPassToTheEnd
|
|
];
|
|
|
|
// NOTE: Result details are not printed for this test because time values are different from machine
|
|
// to machine and run to run. Commenting out the following line turns on detailed logging back on, which
|
|
// can be useful for debugging test failure.
|
|
disableFullTestDetailsPrinting();
|
|
|
|
function PlayWithNoRanges()
|
|
{
|
|
consoleWrite("<br><b><em>Test playing when there are no ranges</em></b>");
|
|
|
|
willPauseInExistingRange = false;
|
|
willExtendAnExistingRange = false;
|
|
timeRangeCount = currentTimeRange = 0;
|
|
|
|
runSilently("video.currentTime = 0.5");
|
|
|
|
currentTimeRange++;
|
|
|
|
waitForEventOnce("seeked", startPlayingInNewRange);
|
|
}
|
|
|
|
|
|
function CreateANewRange()
|
|
{
|
|
consoleWrite("<br><b><em>Create a new range</em></b>");
|
|
|
|
var newTime = (video.played.end(0) + 0.05).toFixed(2);
|
|
runSilently("video.currentTime = " + newTime);
|
|
|
|
willPauseInExistingRange = false;
|
|
willExtendAnExistingRange = false;
|
|
|
|
waitForEventOnce("seeked", startPlayingInNewRange);
|
|
}
|
|
|
|
function JumpAndCollapseTwoRanges()
|
|
{
|
|
consoleWrite("<br><b><em>Test playing from one range into another, should collapse the two ranges</em></b>");
|
|
|
|
timeRangeCount--;
|
|
currentTimeRange = timeRangeCount - 1;
|
|
var startTime = expectedStartTimes[0] - 0.1;
|
|
expectedStartTimes[0] = startTime;
|
|
expectedEndTimes[0] = expectedEndTimes[1];
|
|
|
|
willPauseInExistingRange = false;
|
|
willExtendAnExistingRange = false;
|
|
runSilently("video.currentTime = " + startTime);
|
|
|
|
waitForEventOnce("seeked", function() {
|
|
playForMillisecs(secToMilli(expectedEndTimes[1] - startTime + 0.1)); // Triggers pause()
|
|
});
|
|
}
|
|
|
|
function TestLoopingAndPassToTheEnd()
|
|
{
|
|
consoleWrite("<br><b><em>Test looping</em></b>");
|
|
|
|
// Start playing near the end of the movie so it will loop quickly.
|
|
run("video.loop = true");
|
|
var startTime = (video.duration - 0.05).toFixed(2);
|
|
runSilently("video.currentTime = " + startTime);
|
|
|
|
// We will end in the very first time range
|
|
currentTimeRange = 0;
|
|
|
|
willPauseInExistingRange = true;
|
|
willExtendAnExistingRange = true;
|
|
|
|
// Playing from near the end so we will create a new time range from startTime .. duration
|
|
timeRangeCount++;
|
|
expectedStartTimes[timeRangeCount-1] = startTime;
|
|
expectedEndTimes[timeRangeCount-1] = video.duration.toFixed(2);
|
|
|
|
// Have to play for long enough to loop and play into the existing range.
|
|
var playDuration = 1.25;
|
|
|
|
// Playback restarts from beginning, so expect the beginning of first time range to be 0.
|
|
expectedStartTimes[0] = 0;
|
|
|
|
waitForEventOnce("seeked", function() {
|
|
playForMillisecs(secToMilli(playDuration)); // Triggers pause()
|
|
});
|
|
}
|
|
|
|
</script>
|
|
</head>
|
|
|
|
<body onload="videoPlayedMain()">
|
|
|
|
<video controls></video>
|
|
<p>Test of the media element 'played' attribute</p>
|
|
|
|
</body>
|
|
</html>
|