| 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. | 20 // Content to be played. These files must be the same format. |
| 21 var encryptedContent = '../content/test-encrypted.webm'; | 21 var encryptedContent = '../content/test-encrypted.webm'; |
| 22 var unencryptedContent = '../content/test-vp8-vorbis-webvtt.webm
'; | 22 var unencryptedContent = '../content/test.webm'; |
| 23 | 23 |
| 24 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, |
| 25 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4,
0xae, 0x3c]); | 25 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4,
0xae, 0x3c]); |
| 26 | 26 |
| 27 function onEncrypted(event) | 27 function onEncrypted(event) |
| 28 { | 28 { |
| 29 assert_equals(event.target, video); | 29 assert_equals(event.target, video); |
| 30 assert_true(event instanceof window.MediaEncryptedEvent); | 30 assert_true(event instanceof window.MediaEncryptedEvent); |
| 31 assert_equals(event.type, 'encrypted'); | 31 assert_equals(event.type, 'encrypted'); |
| 32 | 32 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 89 } |
| 90 | 90 |
| 91 function resetSrc() { | 91 function resetSrc() { |
| 92 encryptedEventCount = 0; | 92 encryptedEventCount = 0; |
| 93 video.removeAttribute('src'); | 93 video.removeAttribute('src'); |
| 94 video.load(); | 94 video.load(); |
| 95 return video.setMediaKeys(null); | 95 return video.setMediaKeys(null); |
| 96 } | 96 } |
| 97 | 97 |
| 98 function startPlayback() { | 98 function startPlayback() { |
| 99 // Alternate between encrypted and unencrypted files. | 99 // Alternate between unencrypted and encrypted files. |
| 100 if (playbackCount % 2) { | 100 if (playbackCount % 2) { |
| 101 // Unencrypted files don't require MediaKeys. | 101 // Unencrypted files don't require MediaKeys. |
| 102 video.src = unencryptedContent; | 102 video.src = unencryptedContent; |
| 103 video.play(); | 103 video.play(); |
| 104 return; | 104 return; |
| 105 } | 105 } |
| 106 | 106 |
| 107 navigator.requestMediaKeySystemAccess('org.w3.clearkey', get
ConfigurationForFile(encryptedContent)).then(function(access) { | 107 navigator.requestMediaKeySystemAccess('org.w3.clearkey', get
ConfigurationForFile(encryptedContent)).then(function(access) { |
| 108 return access.createMediaKeys(); | 108 return access.createMediaKeys(); |
| 109 }).then(function(mediaKeys) { | 109 }).then(function(mediaKeys) { |
| 110 return video.setMediaKeys(mediaKeys); | 110 return video.setMediaKeys(mediaKeys); |
| 111 }).then(function(result) { | 111 }).then(function(result) { |
| 112 video.src = encryptedContent; | 112 video.src = encryptedContent; |
| 113 assert_false(video.mediaKeys === null, "video.mediaKeys
is null."); | 113 assert_false(video.mediaKeys === null, "video.mediaKeys
is null."); |
| 114 video.play(); | 114 video.play(); |
| 115 }).catch(function(error) { | 115 }).catch(function(error) { |
| 116 forceTestFailureFromPromise(test, error); | 116 forceTestFailureFromPromise(test, error); |
| 117 }); | 117 }); |
| 118 } | 118 } |
| 119 | 119 |
| 120 waitForEventAndRunStep('playing', video, onPlaying, test); | 120 waitForEventAndRunStep('playing', video, onPlaying, test); |
| 121 waitForEventAndRunStep('encrypted', video, onEncrypted, test); | 121 waitForEventAndRunStep('encrypted', video, onEncrypted, test); |
| 122 startPlayback(); | 122 startPlayback(); |
| 123 }, 'Multiple playbacks alternating between encrypted and clear sourc
es.'); | 123 }, 'Multiple playbacks alternating between encrypted and clear sourc
es.'); |
| 124 </script> | 124 </script> |
| 125 </body> | 125 </body> |
| 126 </html> | 126 </html> |
| OLD | NEW |