| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Clear Key Play Two Videos At Same Time</title> | 4 <title>Clear Key Play Two Videos At Same Time</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 <video id="secondVideo"></video> | 11 <video id="secondVideo"></video> |
| 12 <div id="log"></div> | 12 <div id="log"></div> |
| 13 <script> | 13 <script> |
| 14 // As this code doesn't wait for the 'message' event to simplify | 14 // As this code doesn't wait for the 'message' event to simplify |
| 15 // the code, specify the key ID and key used by the encrypted | 15 // the code, specify the key ID and key used by the encrypted |
| 16 // content. | 16 // content. |
| 17 var keyId = stringToUint8Array('0123456789012345'); | 17 var keyId = stringToUint8Array('0123456789012345'); |
| 18 var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd
2, 0x7b, | 18 var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd
2, 0x7b, |
| 19 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xa
e, 0x3c]); | 19 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xa
e, 0x3c]); |
| 20 var content = '../content/test-encrypted.webm'; |
| 20 | 21 |
| 21 promise_test(function(test) | 22 promise_test(function(test) |
| 22 { | 23 { |
| 23 var promises = [ | 24 var promises = [ |
| 24 play_video_as_promise(document.getElementById('testVideo'),
'../content/test-encrypted.webm'), | 25 play_video_as_promise(document.getElementById('testVideo'),
content), |
| 25 play_video_as_promise(document.getElementById('secondVideo')
, '../content/test-encrypted.webm') | 26 play_video_as_promise(document.getElementById('secondVideo')
, content) |
| 26 ]; | 27 ]; |
| 27 return Promise.all(promises); | 28 return Promise.all(promises); |
| 28 }, 'Play two videos at the same time.'); | 29 }, 'Play two videos at the same time.'); |
| 29 | 30 |
| 30 function play_video_as_promise(video, content) | 31 function play_video_as_promise(video, content) |
| 31 { | 32 { |
| 32 return navigator.requestMediaKeySystemAccess('org.w3.clearkey',
[{}]).then(function(access) { | 33 return navigator.requestMediaKeySystemAccess('org.w3.clearkey',
getConfigurationForFile(content)).then(function(access) { |
| 33 return access.createMediaKeys(); | 34 return access.createMediaKeys(); |
| 34 }).then(function(mediaKeys) { | 35 }).then(function(mediaKeys) { |
| 35 return video.setMediaKeys(mediaKeys); | 36 return video.setMediaKeys(mediaKeys); |
| 36 }).then(function(result) { | 37 }).then(function(result) { |
| 37 video.src = content; | 38 video.src = content; |
| 38 video.play(); | 39 video.play(); |
| 39 return wait_for_encrypted_message(video); | 40 return wait_for_encrypted_message(video); |
| 40 }).then(function(result) { | 41 }).then(function(result) { |
| 41 return wait_for_timeupdate_message(video); | 42 return wait_for_timeupdate_message(video); |
| 42 }); | 43 }); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 if (e.target.currentTime < 0.2) | 77 if (e.target.currentTime < 0.2) |
| 77 return; | 78 return; |
| 78 video.removeEventListener('timeupdate', listener); | 79 video.removeEventListener('timeupdate', listener); |
| 79 resolve(e); | 80 resolve(e); |
| 80 }); | 81 }); |
| 81 }); | 82 }); |
| 82 }; | 83 }; |
| 83 </script> | 84 </script> |
| 84 </body> | 85 </body> |
| 85 </html> | 86 </html> |
| OLD | NEW |