| <html> |
| <head> |
| <title>Test of 'played' attribute</title> |
| <script src=video-test.js></script> |
| <script src=video-played.js></script> |
| <script> |
| |
| var testFunctions = |
| [ |
| PlayWithNoRanges, |
| JumpAndPlayFwd, |
| JumpBackAndPlayToNewRange, |
| JumpAndExtendRangeStart, |
| JumpAndExtendRangeEnd, |
| JumpFwdWithoutPlaying, |
| JumpBackWithoutPlaying, |
| JumpAndExtendRangeStartAndEnd |
| ]; |
| |
| // 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>"); |
| |
| timeRangeCount = currentTimeRange = 0; |
| startPlayingInNewRange(); |
| } |
| |
| function JumpAndPlayFwd() |
| { |
| consoleWrite("<br><b><em>Test jumping forward into a new range and play</em></b>"); |
| |
| var newTime = video.duration - 0.5; |
| runSilently("video.currentTime = " + (newTime.toFixed(2))); |
| currentTimeRange = 1; |
| startPlayingInNewRange(); |
| } |
| |
| function JumpBackAndPlayToNewRange() |
| { |
| consoleWrite("<br><b><em>Test jumping backwards into a new range and play, should insert new range</em></b>"); |
| |
| var newTime = 3.00; |
| runSilently("video.currentTime = " + newTime); |
| |
| currentTimeRange = 1; |
| startPlayingInNewRange(); |
| } |
| |
| function JumpAndExtendRangeStart() |
| { |
| consoleWrite("<br><b><em>Test playing into an existing range, should extend range start</em></b>"); |
| |
| currentTimeRange = 1; |
| var newTime = (video.played.start(currentTimeRange) - 0.05).toFixed(2); |
| runSilently("video.currentTime = " + newTime); |
| |
| expectedStartTimes[currentTimeRange] = newTime; |
| willPauseInExistingRange = true; |
| willExtendAnExistingRange = true; |
| startPlaying(); |
| } |
| |
| function JumpAndExtendRangeEnd() |
| { |
| consoleWrite("<br><b><em>Test jumping into an existing range and play beyond end, should extend range end</em></b>"); |
| |
| currentTimeRange = 1; |
| |
| var newTime = (video.played.end(currentTimeRange) - 0.05).toFixed(2); |
| runSilently("video.currentTime = " + newTime); |
| |
| willPauseInExistingRange = false; |
| willExtendAnExistingRange = true; |
| playForMillisecs(30); |
| } |
| |
| function JumpFwdWithoutPlaying() |
| { |
| consoleWrite("<br><b><em>Test jumping forward without playing, should not create new range</em></b>"); |
| |
| var newTime = (video.played.end(1) + 0.5).toFixed(2); |
| runSilently("video.currentTime = " + newTime); |
| |
| setTimeout(function () { testRanges(); nextTest() }, 10); |
| } |
| |
| function JumpBackWithoutPlaying() |
| { |
| consoleWrite("<br><b><em>Test jumping back without playing, should not create new range</em></b>"); |
| |
| var newTime = (video.played.start(1) - 0.5).toFixed(2); |
| runSilently("video.currentTime = " + newTime); |
| |
| setTimeout(function () { testRanges(); nextTest() }, 10); |
| } |
| |
| function JumpAndExtendRangeStartAndEnd() |
| { |
| consoleWrite("<br><b><em>Test jumping before an existing range and play beyond its end, should extend start and end</em></b>"); |
| |
| currentTimeRange = 1; |
| |
| var newTime = (video.played.start(currentTimeRange) - 0.05).toFixed(2); |
| runSilently("video.currentTime = " + newTime); |
| expectedStartTimes[currentTimeRange] = newTime; |
| |
| willPauseInExistingRange = false; |
| willExtendAnExistingRange = true; |
| playForMillisecs(secToMilli(video.played.end(currentTimeRange) - video.played.start(currentTimeRange) + 0.1)); |
| } |
| |
| </script> |
| </head> |
| |
| <body onload="videoPlayedMain()"> |
| |
| <video controls></video> |
| <p>Test of the media element 'played' attribute</p> |
| |
| </body> |
| </html> |