当我点击在 shiny
应用程序中播放视频时,有没有办法在第二个弹出模式中播放模式内显示的 YouTube 视频?
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(disable = T),
dashboardBody(
actionButton('info', 'Information')
)
)
server <- function(input, output) {
observeEvent(input$info,{
showModal(modalDialog(
title = span(h3(strong("Distribution of cumulative reported cases (logarithmic scale)"), style = 'font-size:16px;color:#6cbabf;')),
fluidRow(
actionButton('hit', 'Open video in popup'),
observeEvent(input$hit,{
showModal(modalDialog(
title = "Video",
HTML(paste0('<iframe width="860" height="500" src="https://www.youtube.com/embed/' ,"aQlTAznANDQ",'" frameborder="0" allowfullscreen></iframe>')),
size = 'l'
))
})
)
))
})
}
shinyApp(ui, server)
最佳答案
试试这个
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
actionButton("show", "Show Video")
)
)
server <- function(input, output) {
observeEvent(input$show, {
showModal(modalDialog(title = "my video",
HTML('<iframe width="560" height="315" src="https://www.youtube.com/embed/aQlTAznANDQ" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>')
)
)
})
}
shinyApp(ui, server)
关于javascript - 在 Shiny 的应用程序中按下时,在另一个弹出模式中播放显示在模式中的 YouTube 视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67751670/