'Unable to render Mp4 Video in R Shiny App
All I get is a solid white background where there should be a video playing. If you click the download link in the shiny app video box, you can download a video that plays as expected in Quicktime.
Link to the source video is here. I placed the video in a www folder where my app.R file lives. I'm on a Mac using Chrome and Safari.
library(shiny)
ui <- fluidPage(
# Application title
titlePanel("Video Compatibility"),
sidebarLayout(
sidebarPanel(
"side bar text"
),
mainPanel(
p("Video Below"),
tags$video(
src = "SampleVideo_640x360_1mb.mp4",
type = "video/mp4",
autoplay=TRUE,
muted=TRUE,
playsinline=TRUE,
loop=TRUE,
controls=TRUE),
p("Video above")
)
)
)
server <- function(input, output) {
}
# Run the application
shinyApp(ui = ui, server = server)
Solution 1:[1]
It looks like when you use shinyApp it will not automatically serve files from the www folder. This is likely because you are passing in functions rather than a path to an application folder so it doesn't assume you want to look in your current directory for files.
Before running shinyApp, you could run
addResourcePath("vid", directoryPath = './www')
and update your path for the video to be
src = "vid/SampleVideo_640x360_1mb.mp4",
This will tell shiny where to look for files with a given URL path prefix.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | MrFlick |
