3 <title>Test of 'played' attribute</title>
4 <script src=media-file.js></script>
5 <script src=video-test.js></script>
6 <script src=video-played.js></script>
13 JumpAndCollapseTwoRanges,
14 TestLoopingAndPassToTheEnd
17 // NOTE: Result details are not printed for this test because time values are different from machine
18 // to machine and run to run. Commenting out the following line turns on detailed logging back on, which
19 // can be useful for debugging test failure.
20 disableFullTestDetailsPrinting();
22 function PlayWithNoRanges()
24 consoleWrite("<br><b><em>Test playing when there are no ranges</em></b>");
26 willPauseInExistingRange = false;
27 willExtendAnExistingRange = false;
28 timeRangeCount = currentTimeRange = 0;
30 runSilently("video.currentTime = 0.5");
33 startPlayingInNewRange();
37 function CreateANewRange()
39 consoleWrite("<br><b><em>Create a new range</em></b>");
41 var newTime = (video.played.end(0) + 0.05).toFixed(2);
42 runSilently("video.currentTime = " + newTime);
44 willPauseInExistingRange = false;
45 willExtendAnExistingRange = false;
47 startPlayingInNewRange();
50 function JumpAndCollapseTwoRanges()
52 consoleWrite("<br><b><em>Test playing from one range into another, should collapse the two ranges</em></b>");
55 currentTimeRange = timeRangeCount - 1;
56 var startTime = expectedStartTimes[0] - 0.1;
57 expectedStartTimes[0] = startTime;
58 expectedEndTimes[0] = expectedEndTimes[1];
60 willPauseInExistingRange = false;
61 willExtendAnExistingRange = false;
62 runSilently("video.currentTime = " + startTime);
64 playForMillisecs(secToMilli(expectedEndTimes[1] - startTime + 0.1)); // Triggers pause()
67 function TestLoopingAndPassToTheEnd()
69 consoleWrite("<br><b><em>Test looping</em></b>");
71 // Start playing near the end of the movie so it will loop quickly.
72 run("video.loop = true");
73 var startTime = (video.duration - 0.05).toFixed(2);
74 runSilently("video.currentTime = " + startTime);
76 // We will end in the very first time range
79 willPauseInExistingRange = true;
80 willExtendAnExistingRange = true;
82 // Playing from near the end so we will create a new time range from startTime .. duration
84 expectedStartTimes[timeRangeCount-1] = startTime;
85 expectedEndTimes[timeRangeCount-1] = video.duration.toFixed(2);
87 // Have to play for long enough to loop and play into the existing range.
88 var playDuration = 1.25;
90 // Playback restarts from beginning, so expect the beginning of first time range to be 0.
91 expectedStartTimes[0] = 0;
92 playForMillisecs(secToMilli(playDuration)); // Triggers pause()
98 <body onload="videoPlayedMain()">
100 <video controls></video>
101 <p>Test of the media element 'played' attribute</p>