From 9d98241a9c52fd91a6dbc9ce18eb2cb1dbd4c7f2 Mon Sep 17 00:00:00 2001 From: Chris Needham Date: Thu, 12 Mar 2020 11:17:53 +0000 Subject: [PATCH] Impove encodingInfo() example - Fix use of `contentType` - Improve error message - Minor code layout change Resolves #149 --- index.bs | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/index.bs b/index.bs index e8197e2..6681b51 100644 --- a/index.bs +++ b/index.bs @@ -1220,26 +1220,29 @@ spec: secure-contexts; urlPrefix: https://www.w3.org/TR/secure-contexts/
           <script>
+            const contentType = 'video/webm;codecs=vp8';
+
             const configuration = {
-                type : 'record',
-                video : {
-                  contentType : 'video/webm;codecs=vp8',
-                  width : 640,
-                  height : 480,
-                  bitrate : 10000,
-                  framerate : 29.97
+              type: 'record',
+              video: {
+                contentType: contentType,
+                width: 640,
+                height: 480,
+                bitrate: 10000,
+                framerate: 29.97
               }
             };
+
             navigator.mediaCapabilities.encodingInfo(configuration)
-                .then((result) => {
-                  console.log(result.contentType + ' is:'
-                      + (result.supported ? '' : ' NOT') + ' supported,'
-                      + (result.smooth ? '' : ' NOT') + ' smooth and'
-                      + (result.powerEfficient ? '' : ' NOT') + ' power efficient');
-                })
-                .catch((err) => {
-                  console.error(err, ' caused encodingInfo to throw');
-                });
+              .then((result) => {
+                console.log(contentType + ' is:'
+                  + (result.supported ? '' : ' NOT') + ' supported,'
+                  + (result.smooth ? '' : ' NOT') + ' smooth and'
+                  + (result.powerEfficient ? '' : ' NOT') + ' power efficient');
+              })
+              .catch((err) => {
+                console.error(err, ' caused encodingInfo to reject');
+              });
           </script>