| OLD | NEW |
| 1 var consoleDiv = null; | 1 var consoleDiv = null; |
| 2 | 2 |
| 3 function consoleWrite(text) | 3 function consoleWrite(text) |
| 4 { | 4 { |
| 5 if (!consoleDiv && document.body) { | 5 if (!consoleDiv && document.body) { |
| 6 consoleDiv = document.createElement('div'); | 6 consoleDiv = document.createElement('div'); |
| 7 document.body.appendChild(consoleDiv); | 7 document.body.appendChild(consoleDiv); |
| 8 } | 8 } |
| 9 var span = document.createElement('span'); | 9 var span = document.createElement('span'); |
| 10 span.appendChild(document.createTextNode(text)); | 10 span.appendChild(document.createTextNode(text)); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 return [ { | 84 return [ { |
| 85 initDataTypes: [ initDataType ], | 85 initDataTypes: [ initDataType ], |
| 86 audioCapabilities: getPossibleAudioCapabilities() | 86 audioCapabilities: getPossibleAudioCapabilities() |
| 87 } ]; | 87 } ]; |
| 88 } | 88 } |
| 89 | 89 |
| 90 // Returns a MediaKeySystemConfiguration for |mediaFile| that specifies | 90 // Returns a MediaKeySystemConfiguration for |mediaFile| that specifies |
| 91 // both audio and video capabilities for the specified file.. | 91 // both audio and video capabilities for the specified file.. |
| 92 function getConfigurationForFile(mediaFile) | 92 function getConfigurationForFile(mediaFile) |
| 93 { | 93 { |
| 94 if (mediaFile.toLowerCase().endsWith('webm')) { | 94 if (mediaFile.toLowerCase().endsWith('.webm')) { |
| 95 return [ { | 95 return [ { |
| 96 initDataTypes: [ 'webm' ], | 96 initDataTypes: [ 'webm' ], |
| 97 audioCapabilities: [ { contentType: 'audio/webm; codecs="opus"' } ], | 97 audioCapabilities: [ { contentType: 'audio/webm; codecs="opus"' } ], |
| 98 videoCapabilities: [ { contentType: 'video/webm; codecs="vp8"' } ] | 98 videoCapabilities: [ { contentType: 'video/webm; codecs="vp8"' } ] |
| 99 } ]; | 99 } ]; |
| 100 } | 100 } |
| 101 | 101 |
| 102 // NOTE: Supporting other mediaFormats is not currently implemented as | 102 // NOTE: Supporting other mediaFormats is not currently implemented as |
| 103 // Chromium only tests with WebM files. | 103 // Chromium only tests with WebM files. |
| 104 throw 'mediaFile ' + mediaFile + ' not supported.'; | 104 throw 'mediaFile ' + mediaFile + ' not supported.'; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 // Decode the first element of 'kids'. | 287 // Decode the first element of 'kids'. |
| 288 assert_equals(1, json.kids.length); | 288 assert_equals(1, json.kids.length); |
| 289 var decoded_key = base64urlDecode(json.kids[0]); | 289 var decoded_key = base64urlDecode(json.kids[0]); |
| 290 // Convert to an Uint8Array and return it. | 290 // Convert to an Uint8Array and return it. |
| 291 return stringToUint8Array(decoded_key); | 291 return stringToUint8Array(decoded_key); |
| 292 } | 292 } |
| 293 | 293 |
| 294 // Create a MediaKeys object for Clear Key with 1 session. KeyId and key | 294 // Create a MediaKeys object for Clear Key with 1 session. KeyId and key |
| 295 // required for the video are already known and provided. Returns a promise | 295 // required for the video are already known and provided. Returns a promise |
| 296 // that resolves to the MediaKeys object created. | 296 // that resolves to the MediaKeys object created. |
| 297 function createMediaKeys(keyId, key) | 297 function createClearKeyMediaKeysAndInitializeWithOneKey(keyId, key) |
| 298 { | 298 { |
| 299 var mediaKeys; | 299 var mediaKeys; |
| 300 var mediaKeySession; | 300 var mediaKeySession; |
| 301 var request = stringToUint8Array(createKeyIDs(keyId)); | 301 var request = stringToUint8Array(createKeyIDs(keyId)); |
| 302 var jwkSet = stringToUint8Array(createJWKSet(createJWK(keyId, key))); | 302 var jwkSet = stringToUint8Array(createJWKSet(createJWK(keyId, key))); |
| 303 | 303 |
| 304 return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleCon
figurationForInitDataType('keyids')).then(function(access) { | 304 return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleCon
figurationForInitDataType('keyids')).then(function(access) { |
| 305 return access.createMediaKeys(); | 305 return access.createMediaKeys(); |
| 306 }).then(function(result) { | 306 }).then(function(result) { |
| 307 mediaKeys = result; | 307 mediaKeys = result; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 322 video.play(); | 322 video.play(); |
| 323 return new Promise(function(resolve) { | 323 return new Promise(function(resolve) { |
| 324 video.addEventListener('timeupdate', function listener(event) { | 324 video.addEventListener('timeupdate', function listener(event) { |
| 325 if (event.target.currentTime < duration) | 325 if (event.target.currentTime < duration) |
| 326 return; | 326 return; |
| 327 video.removeEventListener('timeupdate', listener); | 327 video.removeEventListener('timeupdate', listener); |
| 328 resolve('success'); | 328 resolve('success'); |
| 329 }); | 329 }); |
| 330 }); | 330 }); |
| 331 } | 331 } |
| OLD | NEW |