blob: cb477f4e3f8526db89b31333b20f26ffb2b8d87a [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>test playbackRate and defaultPlaybackRate</title>
<script src=media-file.js></script>
<script src=video-test.js></script>
<script>
var wallClockAtFirstTimeUpdate;
var mediaTimeAtFirstTimeUpdate;
var effectivePlaybackRate;
function start()
{
findMediaElement();
waitForEvent('canplaythrough', canplaythrough);
run('video.defaultPlaybackRate = 0.5');
setSrcByTagName('video', findMediaFile('video', 'content/test'));
}
function canplaythrough()
{
testExpected('video.playbackRate', 0.5);
testExpected('video.defaultPlaybackRate', 0.5);
waitForEvent('timeupdate', timeupdate);
video.play();
}
function timeupdate()
{
var now = Date.now() / 1000;
if (!wallClockAtFirstTimeUpdate) {
wallClockAtFirstTimeUpdate = now;
mediaTimeAtFirstTimeUpdate = video.currentTime;
return;
}
if (wallClockAtFirstTimeUpdate == now)
return;
var wallClockDelta = wallClockAtFirstTimeUpdate - now;
var mediaTimeDelta = mediaTimeAtFirstTimeUpdate - video.currentTime;
effectivePlaybackRate = mediaTimeDelta / wallClockDelta;
testExpected('effectivePlaybackRate', .75, '<');
endTest();
}
</script>
</head>
<body onload="start()">
<video controls></video>
</body>
</html>