Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 91 lines (77 sloc) 3.511 kB
b47ddd5 2011-03-29 Eric Carlson <eric.carlson@apple.com>
eric.carlson@apple.com authored
1
2 <html>
3 <head>
4 <!-- LayoutTests location is hard-coded to avoid duplication of code. -->
5 <script src="http://svn.webkit.org/repository/webkit/trunk/LayoutTests/media/media-file.js"></script>
6 <script src="http://svn.webkit.org/repository/webkit/trunk/LayoutTests/media/video-test.js"></script>
7
8 <script>
9 var expectedRates = { "defaultPlaybackRate" : 1, "playbackRate" : 1};
10 var playingFromScript = false;
11 var changedRate = false;
12
13 function absoluteUrl(url)
14 {
15 var a = document.createElement('a');
16 a.href = url;
17 return a.href;
18 }
19
20 function testRates()
21 {
22 consoleWrite("");
23 var playWithControllerButton = !changedRate && !playingFromScript;
24 testExpected("video.playbackRate", playWithControllerButton ? expectedRates['defaultPlaybackRate'] : expectedRates['playbackRate']);
25 testExpected("video.defaultPlaybackRate", expectedRates['defaultPlaybackRate']);
26 changedRate = false;
27 }
28
29 function playing()
30 {
31 consoleWrite("<br>'playing' event");
32 expectedRates['playbackRate'] = playingFromScript ? video.playbackRate : video.defaultPlaybackRate;
33 testRates();
34 playingFromScript = false;
35 }
36
37 function ratechange()
38 {
39 consoleWrite("<br>'ratechange' event");
40 testRates();
41 }
42
43 function start()
44 {
45 findMediaElement();
46 video.addEventListener('ratechange', ratechange);
47 video.addEventListener('playing', playing);
48
49 // Use the video file from the svn repository to avoid duplicating the file.
50 video.src = absoluteUrl(findMediaFile('video', 'http://svn.webkit.org/repository/webkit/trunk/LayoutTests/media/content/test'));
51 testRates();
52 }
53
54 function play()
55 {
56 playingFromScript = true;
57 video.play();
58 }
59
60 function setRate(which, rate)
61 {
62 changedRate = true;
63 video[which] = rate;
64 expectedRates[which] = rate;
65 }
66
67 </script>
68 </head>
69
70 <body onload="start()">
71
72 <video controls > </video>
73 <ul>
74 <li>The current 'playbackRate' and 'defaultPlaybackRate' should be logged every time either changes.</li>
75 <li>'playbackRate' should be set to 'defaultPlaybackRate' when the Play button in the built-in controls is pressed</li>
76 <li>'playbackRate' should NOT when play() is called from script.</li>
77 </ul>
78 <div>
79 <button id="controls" onclick="setRate('defaultPlaybackRate', 2)">defaultPlaybackRate = 2</button>
80 <button id="controls" onclick="setRate('defaultPlaybackRate', 1)">defaultPlaybackRate = 1</button>
81 <button id="controls" onclick="setRate('playbackRate', 2)">playbackRate = 2</button>
82 <button id="controls" onclick="setRate('playbackRate', 1)">playbackRate = 1</button>
83 </div>
84 <div>
85 <button id="controls" onclick="play()">play()</button>
86 <button id="controls" onclick="video.pause()">pause()</button>
87 </div>
88 <br>
89 </body>
90 </html>
Something went wrong with that request. Please try again.