App.svelte
`
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
<script> let videoSource = null; let loading = false; const obtenerVideoCamara = async () => { try { loading = true; const stream = await navigator.mediaDevices.getUserMedia({ video: true, }); videoSource.srcObject = stream; videoSource.play(); loading = false; } catch (error) { console.log(error); } }; </script> <div> {#if loading} <h1>CARGANDO</h1> {/if} <!-- svelte-ignore a11y-media-has-caption --> <video bind:this={videoSource} /> <button on:click={obtenerVideoCamara}>CLICK</button> </div> |