Executing JavaScript

Hello Radzen Team!

I'm trying to play a webcam in my server-side Blazor app, using the webcamjs lib.
This is what's in my .razor page:

<div id="camera" style="width: 320px; height: 240px;">
      <div></div>
      <video autoplay="autoplay" playsinline="playsinline" style="width: 320px; height: 240px;"></video>
    </div>
    <button @onclick="Play">Play</button>
    @code {
      void Play() {
        JSRuntime.InvokeVoidAsync("play");
      }
    }

And this is what I have in the _Host.cshtml page:

<script type="text/javascript" src="assets/sdks/webcamjs/webcam.js"></script>
    <script language="JavaScript">
      function play() {  
    Webcam.set({
      width: 320,
      height: 240,
      image_format: 'jpeg',
      jpeg_quality: 90
    });
    Webcam.attach($("#camera") );
      }
  </script>

How can I make sure that the .js code is actually being executed?

1 Like

Hi @kim,

Not sure if this question is related to Radzen - your code contains zero Radzen related code :slight_smile:

Anyway I would use console.log to check if a code is executed or not.

1 Like