dino@apple.com | d039aa2 | 2013-10-07 20:04:46 +0000 | [diff] [blame] | 1 | <html> |
| 2 | <head> |
| 3 | <title>Drawing to canvas using video</title> |
| 4 | <script src=media-file.js></script> |
| 5 | <script> |
| 6 | var video; |
| 7 | var numberOfSeeks = 4; |
| 8 | var requirePixelDump = true; |
| 9 | |
| 10 | if (window.testRunner) { |
| 11 | testRunner.dumpAsText(true); |
| 12 | testRunner.waitUntilDone(); |
| 13 | } |
| 14 | |
| 15 | function drawAndInsertFrame() |
| 16 | { |
| 17 | var canvas = document.createElement('canvas'); |
| 18 | canvas.width = video.videoWidth / 2; |
| 19 | canvas.height = video.videoHeight / 2; |
| 20 | canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height); |
| 21 | |
| 22 | document.getElementById('canvases').appendChild(canvas); |
| 23 | |
| 24 | if (--numberOfSeeks) { |
| 25 | video.currentTime += 1; |
| 26 | return; |
| 27 | } |
| 28 | |
| 29 | endTest(); |
| 30 | } |
| 31 | |
| 32 | function canplaythrough() |
| 33 | { |
| 34 | video.currentTime = 3; |
| 35 | } |
| 36 | |
| 37 | function start() |
| 38 | { |
| 39 | findMediaElement(); |
| 40 | waitForEvent('canplaythrough', canplaythrough); |
| 41 | waitForEvent('seeked', drawAndInsertFrame); |
| 42 | video.src = findMediaFile('video', 'content/counting'); |
| 43 | } |
| 44 | </script> |
| 45 | <script src=video-test.js></script> |
| 46 | </head> |
| 47 | <body onload="start()"> |
| 48 | <video id="video"></video> |
| 49 | <div id="canvases"></div> |
| 50 | </body> |
| 51 | </html> |