blob: eb1b38c5daba08c6e25decc31af10888e0613a21 [file] [log] [blame]
<!DOCTYPE html>
<title>Decode Capabilities Test</title>
<div id="console"></div>
<script type='text/javascript'>
function log(message) {
let consoleElement = document.getElementById('console');
let entry = document.createElement('div');
entry.appendChild(document.createTextNode(message));
consoleElement.appendChild(entry);
console.log(message);
}
function runTest(configuration) {
try {
navigator.mediaCapabilities.decodingInfo(configuration)
.then((result) => {
log('Decoding is '
+ (result.supported ? '' : 'un') + 'supported');
document.title = result.supported ? 'SUPPORTED' : 'UNSUPPORTED';
})
.catch((e) => {
log('Promise rejected: ' + e);
document.title = "ERROR";
});
} catch (e) {
log('Exception:' + e);
document.title = "ERROR";
}
}
function testVideoConfig(queryType, contentType) {
// Clear previous test result from title.
document.title = '';
log("Testing video content type: " + contentType);
const configuration = {
type : queryType,
video : {
contentType : contentType,
// Any reasonable value will do.
width : 640,
height : 480,
bitrate : 10000,
framerate : 30
}
};
runTest(configuration);
}
function testAudioConfig(queryType, contentType) {
// Clear previous test result from title.
document.title = '';
log("Testing audio content type: " + contentType);
const configuration = {
type : queryType,
audio : {
contentType : contentType
}
};
runTest(configuration);
}
</script>