Created
November 26, 2023 15:58
-
-
Save simonespa/1f2d8fd84adfa1c84eeeeef95006da7a to your computer and use it in GitHub Desktop.
Some old web stuff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <script type="text/javascript"> | |
| // uniformo la chiamata a getUserMedia rispetto ai vari prefissi sperimentali | |
| navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; | |
| // uniformo la chiamata a window.URL sempre rispetto ai prefissi sperimentali | |
| window.URL = window.URL || window.webkitURL; | |
| // invoco la richiesta di accedere sia al flusso video che quello audio, la funzione | |
| // passata come secondo parametro viene lanciata in caso di successo, quella come | |
| // parametro in caso di errore o di negata autorizzazione | |
| navigator.getUserMedia({video: true}, function(localMediaStream) { | |
| // creo un elemento HTML5 video ed imposto come sorgente lo stream | |
| // proveniente dalla telecamera. | |
| var video = document.createElement("video"); | |
| video.autoplay = true; | |
| video.src = window.URL ? window.URL.createObjectURL(localMediaStream) : localMediaStream; | |
| // aggancio l'elemento video al body della pagina HTML. | |
| document.body.appendChild(video); | |
| }, | |
| function(error) { | |
| console.log(error); | |
| }); | |
| </script> | |
| </head> | |
| <body> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment