Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Multiple playbacks alternating between encrypted and clear source s.</title> | 4 <title>Multiple playbacks alternating between encrypted and clear source s.</title> |
| 5 <script src="encrypted-media-utils.js"></script> | 5 <script src="encrypted-media-utils.js"></script> |
| 6 <script src="../../resources/testharness.js"></script> | 6 <script src="../../resources/testharness.js"></script> |
| 7 <script src="../../resources/testharnessreport.js"></script> | 7 <script src="../../resources/testharnessreport.js"></script> |
| 8 </head> | 8 </head> |
| 9 <body> | 9 <body> |
| 10 <video id="testVideo"></video> | 10 <video id="testVideo"></video> |
| 11 <div id="log"></div> | 11 <div id="log"></div> |
| 12 <script> | 12 <script> |
| 13 async_test(function(test) | 13 async_test(function(test) |
| 14 { | 14 { |
| 15 var video = document.getElementById('testVideo'); | 15 var video = document.getElementById('testVideo'); |
| 16 var isUpdatePromiseResolved = false; | 16 var isUpdatePromiseResolved = false; |
| 17 var encryptedEventCount = 0; | 17 var encryptedEventCount = 0; |
| 18 var playbackCount = 0; | 18 var playbackCount = 0; |
| 19 | 19 |
| 20 // Content to be played. These files must be the same format. | |
| 21 var encryptedContent = '../content/test-encrypted.webm'; | |
| 22 var unencryptedContent = '../content/test-vp8-vorbis-webvtt.webm '; | |
|
ddorwin
2016/07/20 19:34:20
Any idea why we use this file? It seems we should
| |
| 23 | |
| 20 var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, | 24 var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, |
| 21 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]); | 25 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]); |
| 22 | 26 |
| 23 function onEncrypted(event) | 27 function onEncrypted(event) |
| 24 { | 28 { |
| 25 assert_equals(event.target, video); | 29 assert_equals(event.target, video); |
| 26 assert_true(event instanceof window.MediaEncryptedEvent); | 30 assert_true(event instanceof window.MediaEncryptedEvent); |
| 27 assert_equals(event.type, 'encrypted'); | 31 assert_equals(event.type, 'encrypted'); |
| 28 | 32 |
| 29 // The same decryption key is used by both the audio and | 33 // The same decryption key is used by both the audio and |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 } | 89 } |
| 86 | 90 |
| 87 function resetSrc() { | 91 function resetSrc() { |
| 88 encryptedEventCount = 0; | 92 encryptedEventCount = 0; |
| 89 video.removeAttribute('src'); | 93 video.removeAttribute('src'); |
| 90 video.load(); | 94 video.load(); |
| 91 return video.setMediaKeys(null); | 95 return video.setMediaKeys(null); |
| 92 } | 96 } |
| 93 | 97 |
| 94 function startPlayback() { | 98 function startPlayback() { |
| 99 // Alternate between encrypted and unencrypted files. | |
| 95 if (playbackCount % 2) { | 100 if (playbackCount % 2) { |
| 96 video.src = '../content/test-vp8-vorbis-webvtt.webm'; | 101 // Unencrypted files don't require MediaKeys. |
|
ddorwin
2016/07/20 19:34:20
Since we start with clear, we should probably swit
| |
| 102 video.src = unencryptedContent; | |
| 97 video.play(); | 103 video.play(); |
| 98 return; | 104 return; |
| 99 } | 105 } |
| 100 | 106 |
| 101 navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{} ]).then(function(access) { | 107 navigator.requestMediaKeySystemAccess('org.w3.clearkey', get ConfigurationForFile(encryptedContent)).then(function(access) { |
| 102 return access.createMediaKeys(); | 108 return access.createMediaKeys(); |
| 103 }).then(function(mediaKeys) { | 109 }).then(function(mediaKeys) { |
| 104 return video.setMediaKeys(mediaKeys); | 110 return video.setMediaKeys(mediaKeys); |
| 105 }).then(function(result) { | 111 }).then(function(result) { |
| 106 video.src = '../content/test-encrypted.webm'; | 112 video.src = encryptedContent; |
| 107 assert_false(video.mediaKeys === null, "video.mediaKeys is null."); | 113 assert_false(video.mediaKeys === null, "video.mediaKeys is null."); |
| 108 video.play(); | 114 video.play(); |
| 109 }).catch(function(error) { | 115 }).catch(function(error) { |
| 110 forceTestFailureFromPromise(test, error); | 116 forceTestFailureFromPromise(test, error); |
| 111 }); | 117 }); |
| 112 } | 118 } |
| 113 | 119 |
| 114 waitForEventAndRunStep('playing', video, onPlaying, test); | 120 waitForEventAndRunStep('playing', video, onPlaying, test); |
| 115 waitForEventAndRunStep('encrypted', video, onEncrypted, test); | 121 waitForEventAndRunStep('encrypted', video, onEncrypted, test); |
| 116 startPlayback(); | 122 startPlayback(); |
| 117 }, 'Multiple playbacks alternating between encrypted and clear sourc es.'); | 123 }, 'Multiple playbacks alternating between encrypted and clear sourc es.'); |
| 118 </script> | 124 </script> |
| 119 </body> | 125 </body> |
| 120 </html> | 126 </html> |
| OLD | NEW |