I was wondering, is it possible to use the HTML()
function in R shiny to excute an html5 code that will allow me to access my webcam from my browser (similar to what was proposed in this topic: Access camera from a browser)
Here is my example:
library(shiny)
ui <- fluidPage(
titlePanel(title = "Test Cam App",windowTitle = "Test Cam App"),
wellPanel(uiOutput("video"))
)
server <- function(input, output, session) {
output$video <- renderUI(HTML("
<video autoplay></video>
<script>
var onFailSoHard = function(e) {
console.log('Reeeejected!', e);
};
navigator.getUserMedia({video: true, audio: true}, function(localMediaStream) {
var video = document.querySelector('video');
video.src = window.URL.createObjectURL(localMediaStream);
video.onloadedmetadata = function(e) {
};
}, onFailSoHard);
</script>
"))
}
shinyApp(ui = ui, server = server)
When I run the app on a browser (chrome) I get the message to unable my camera, and I also get the camera icon, however the video input is not displayed: