| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Encrypted Media Player</title> | 4 <title>Encrypted Media Player</title> |
| 5 </head> | 5 </head> |
| 6 <body onload="runTest();"> | 6 <body onload="runTest();"> |
| 7 <video controls></video> | 7 <video controls></video> |
| 8 <script src="encrypted_media_utils.js" type="text/javascript"></script> | 8 <script src="encrypted_media_utils.js" type="text/javascript"></script> |
| 9 <script type="text/javascript"> | 9 <script type="text/javascript"> |
| 10 var video = document.querySelector('video'); | 10 var video = document.querySelector('video'); |
| 11 | 11 |
| 12 function onTimeUpdate() { | 12 function onTimeUpdate() { |
| 13 // webkitkeyadded should have been fired before playback. | 13 if (video.currentTime < 1) |
| 14 return; |
| 15 // keyadded may be fired around the start of playback; check for it |
| 16 // after a delay to avoid timing issues. |
| 14 if (!video.receivedKeyAdded) | 17 if (!video.receivedKeyAdded) |
| 15 failTest('Key added event not received.'); | 18 failTest('Key added event not received.'); |
| 16 if (video.currentTime < 1) | |
| 17 return; | |
| 18 if (video.isHeartbeatExpected && !video.receivedHeartbeat) | 19 if (video.isHeartbeatExpected && !video.receivedHeartbeat) |
| 19 failTest('Heartbeat keymessage event not received.'); | 20 failTest('Heartbeat keymessage event not received.'); |
| 20 video.removeEventListener('ended', failTest); | 21 video.removeEventListener('ended', failTest); |
| 21 installTitleEventHandler(video, 'ended'); | 22 installTitleEventHandler(video, 'ended'); |
| 22 video.removeEventListener('timeupdate', onTimeUpdate); | 23 video.removeEventListener('timeupdate', onTimeUpdate); |
| 23 } | 24 } |
| 24 | 25 |
| 25 // The test completes after playing the encrypted media for 1 second and | 26 // The test completes after playing the encrypted media for 1 second and |
| 26 // getting the ended event or when an error occurs at any time. | 27 // getting the ended event or when an error occurs at any time. |
| 27 function runTest() { | 28 function runTest() { |
| 28 loadEncryptedMediaFromURL(video); | 29 loadEncryptedMediaFromURL(video); |
| 29 video.addEventListener('timeupdate', onTimeUpdate); | 30 video.addEventListener('timeupdate', onTimeUpdate); |
| 30 video.play(); | 31 video.play(); |
| 31 } | 32 } |
| 32 </script> | 33 </script> |
| 33 </body> | 34 </body> |
| 34 </html> | 35 </html> |
| OLD | NEW |