How to embed videos in Shiny

I would like to embed a short mp4 video from Google Drive into my Shiny App.

Here is my UI:

ui <- navbarPage(strong("Balltistics - 2018"), 
                 theme = shinytheme("yeti"),
                 collapsible = T,
                     selectInput(inputId = "dataset",
                                 label = "Select Dataset:",
                                 choices = c("NBA Players 2018",
                                             "NBA Teams 2018",
                                             "NBA 4th Quarter Lineups",
                                             "WNBA Players 2018",
                                             "WNBA Teams 2018",
                                             "WNBA 4th Quarter Lineups")),
                     selectInput(inputId = "stat",
                                 label = "Select Stat of Interest:",
                                 choices = ""),
                     h3("Stuck? Here's some instructional videos!", br()),
                     a(href = "",
                       "Balltistics Instructional Video (Teams)"),
                     a(href = "",
                       "Balltistics Instructional Video (Lineups)"),
                     a(href = "",
                       "Balltistics Instructional Video (Players)")),
                     h4("Data Snippet"),
                     shiny::tags$video(src = "Brush Tool Gif.mp4",
                                type = "video/mp4"))),
                 tabPanel("Graphs", icon = icon("bar-chart-o"),
                          h2("Team Graphs"),
                          h2("Lineup Graphs"),
                          plotOutput("scatter", brush = brushOpts(id = "plot_brush")),
                          h4("Brush the plot to view lineups of interest"),
                          sliderInput(inputId = "avg_pm",
                                      label = "Set Range for Plus/Minus Score",
                                      value = c(0,10), min = min(wnba_q4_lineups$PLUS_MINUS),
                                      max = max(wnba_q4_lineups$PLUS_MINUS)),
                          h2("Player Graphs"),
                          plotOutput("scatter2", brush = brushOpts(id = "plot_brush2")),
                          h4("Brush the plot to view players of interest"),
                 tabPanel("Full Data Table", icon = icon("table"),

I'm wondering if I've placed the video incorrectly? Does it not show up because it's in the Main Panel? Or is it because its not saved properly?

Please help!

This simpler reprex works:

ui <- fluidPage(
  HTML('<iframe width="560" height="315" src="" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>')
server <- function(input, output, session) {
shinyApp(ui, server)

So it's not something general to Shiny.

There's also tags$iframe():

ui <- fluidPage(
    tags$iframe(width="560", height="315", src="", frameborder="0", allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture", allowfullscreen=NA)
server <- function(input, output, session) {
shinyApp(ui, server)

So, I'm seeing a pattern that the best practice is to simply use HTML and iframes. Am I right?

Also, I tried to put this video

into the app and it shows the space where the video would pop up, but it doesn't play. I know the video is saved in Google drive. Is that a problem?

And thank you Hadley for responding, you're a legend!

I wouldn't say it's best practice, just that it confirms it is at least possible to embed a video, so it's not a general problem with videos + shiny. Unfortunately I don't understand how video streaming works on the web these days, but I would be surprised if just linking to a file on google drive works.

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