Video output in Shiny using HTML


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:


ui <- fluidPage(
  titlePanel(title = "Test Cam App",windowTitle = "Test Cam App"),



server <- function(input, output, session) {

  output$video <- renderUI(HTML("
       <video autoplay></video>
       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);


shinyApp(ui = ui, server = server)

I don't have the answer to your question directly, but maybe consider this R package which provides functions for capturing images with your webcam (e.g. shinyviewr). Maybe it will be helpful.

Hello Matt,
Thanks for the answer, yes I'm already familiar with the shinyviewr package, however, I was curious if it's possible to use directly an html5 code to get the webcam video input.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.