在闪亮的应用程序中按下时,播放在另一个弹出模式中以模式显示的 youtube 视频

Play youtube video that is displayed in a modal in an another pop up modal when pressed in a shiny app

当我在 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)

我无法点击视频,但也许这样的方法行得通?

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(disable = T),
  dashboardBody(
    actionButton('hit', 'Open video in popup')
  )
)

server <- function(input, output) {
  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)