Mediarecorder-photocomplete returning {isTrusted: false}

Howdy,

In the Cloud-Editor simulator, when using the mediarecordere-photocomplete event to capture a photo, the event data only contains {isTrusted: false}. I expected that it would contain more information such as the blob.

I assume I haven’t configured something correctly or perhaps it’s something to do with the simulator.

Any advice around this problem would be much appreciated!

const scanComponent = {
  init() {
    window.addEventListener('mediarecorder-photocomplete', (e) => {
      console.log({...e})
      if (e.detail.blob) {
        const scanner = new jscanify()
        const paperWidth = 2480
        const paperHeight = 3508

        // Create an image element from the blob
        const {blob} = e.detail
        const url = URL.createObjectURL(blob)
        const img = new Image()

        console.log({...e})

        img.onload = function () {
          console.log('IMAGE LOADED')
          const resultCanvas = scanner.extractPaper(img, paperWidth, paperHeight)
          document.body.appendChild(resultCanvas)

          // Clean up
          URL.revokeObjectURL(url)
        }

        img.onerror = function () {
          console.error('Failed to load image from blob')
        }

        img.src = url
      }
    })
  },
}

AFRAME.registerComponent('scanner', scanComponent)

The MediaRecorder source code is available here: web/xrextras/src/mediarecorder at master · 8thwall/web · GitHub

Hopefully that can help. :slight_smile:

1 Like