OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>Decode Capabilities Test</title> |
| 3 <div id="console"></div> |
| 4 <script type='text/javascript'> |
| 5 function log(message) { |
| 6 let consoleElement = document.getElementById('console'); |
| 7 let entry = document.createElement('div'); |
| 8 entry.appendChild(document.createTextNode(message)); |
| 9 consoleElement.appendChild(entry); |
| 10 console.log(message); |
| 11 } |
| 12 |
| 13 function runTest(configuration) { |
| 14 try { |
| 15 navigator.mediaCapabilities.decodingInfo(configuration) |
| 16 .then((result) => { |
| 17 log('Decoding is ' |
| 18 + (result.supported ? '' : 'un') + 'supported'); |
| 19 |
| 20 document.title = result.supported ? 'SUPPORTED' : 'UNSUPPORTED'; |
| 21 }) |
| 22 .catch((e) => { |
| 23 log('Promise rejected: ' + e); |
| 24 document.title = "ERROR"; |
| 25 }); |
| 26 |
| 27 } catch (e) { |
| 28 log('Exception:' + e); |
| 29 document.title = "ERROR"; |
| 30 } |
| 31 } |
| 32 |
| 33 function testVideoDecodeContentType(contentType) { |
| 34 // Clear previous test result from title. |
| 35 document.title = ''; |
| 36 |
| 37 log("Testing video content type: " + contentType); |
| 38 |
| 39 const configuration = { |
| 40 // TODO(chcunningham): Add tests for type: "media-source". |
| 41 type : 'file', |
| 42 video : { |
| 43 contentType : contentType, |
| 44 |
| 45 // Any reasonable value will do. |
| 46 width : 640, |
| 47 height : 480, |
| 48 bitrate : 10000, |
| 49 framerate : 30 |
| 50 } |
| 51 }; |
| 52 |
| 53 runTest(configuration); |
| 54 } |
| 55 |
| 56 function testAudioDecodeContentType(contentType) { |
| 57 // Clear previous test result from title. |
| 58 document.title = ''; |
| 59 |
| 60 log("Testing audio content type: " + contentType); |
| 61 |
| 62 const configuration = { |
| 63 // TODO(chcunningham): Add tests for type: "media-source". |
| 64 type : 'file', |
| 65 audio : { |
| 66 contentType : contentType |
| 67 } |
| 68 }; |
| 69 |
| 70 runTest(configuration); |
| 71 } |
| 72 </script> |
OLD | NEW |