所以我嘗試使用 Shiny 中的 fileInput 小部件上傳視頻,然后將該視頻顯示在 mainPanel 中。我是 R 的新手,并使用了多種示例來嘗試找到解決方案,因此如果有任何代碼錯誤,那就是原因。在此先感謝您的幫助!
我的用戶界面腳本:
library(shiny)
shinyUI(fluidPage(
headerPanel(title = 'Shiny Example'),
sidebarLayout(
sidebarPanel(
fileInput("file", "Choose Video File", accept = ".mp4"),
uiOutput("selectfile")
),
mainPanel(
uiOutput('video')
)
)
)
)
我的服務器腳本:
library(shiny)
shinyServer(function(input, output) {})
uj5u.com熱心網友回復:
適用于 Firefox:
library(shiny)
options(shiny.maxRequestSize = 30*1024^2)
ui <- fluidPage(
headerPanel(title = 'Shiny Example'),
sidebarLayout(
sidebarPanel(
fileInput("file", "Choose Video File", accept = ".mp4")
),
mainPanel(
uiOutput('video')
)
)
)
server <- function(input, output){
Video <- eventReactive(input[["file"]], {
input[["file"]][["datapath"]]
})
output[["video"]] <- renderUI({
req(Video())
file.rename(Video(), "www/myvideo.mp4")
tags$video(
width="320", height="240", controls="",
tags$source(src="myvideo.mp4", type="video/mp4")
)
})
}
shinyApp(ui, server)
您必須有一個www子檔案夾。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/324562.html
上一篇:將電話國家代碼轉換為國家名稱
