微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用 actionButton() 在闪亮仪表板的模态对话框中播放视频

如何解决使用 actionButton() 在闪亮仪表板的模态对话框中播放视频

我在下面有一个闪亮的仪表板,其中包含一个 actionButton()。当按下此按钮时,会出现一个带有另一个 actionButton() 的模式对话框。当我按下它时,我希望可以从 here 下载并保存在名为 www 的子目录中的视频在模态中显示和播放。我也对 youtube 视频开放,但它应该在按下按钮后显示

    library(shiny)
    library(shinydashboard)
    
    ui <- dashboardPage(
      dashboardHeader(titleWidth = 0
                      # Set height of dashboardHeader
                      ),dashboardSidebar(),dashboardBody(
        tags$div(style="display:inline-block",title="Using the range slider",actionButton("info","",icon = icon("info-circle"),style='padding:10px; font-size:80%')),)
    )
    
    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;')),tags$div(style="display:inline-block",actionButton("play",icon = icon("play"),#tags$video(id="video2",type = "mov",src = "Screen Recording 2021-05-25 at 4.03.51 AM.mov",controls = "controls")
#or youtube file
        HTML('<iframe width="200" height="100" src="//www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allowfullscreen></iframe>') )

          
        ))
        
      })
      
    }
    
    shinyApp(ui,server)

解决方法

试试这个:

showModal(modalDialog(
  title = span(h3(strong("Distribution of cumulative reported cases (logarithmic scale)"),style = 'font-size:16px;color:#6cbabf;')),tags$div(
    style = "display:inline-block",title = "Using the range slider",actionButton(
      "play","",icon = icon("play"),style = 'padding:10px; font-size:80%',onclick = "document.getElementById('video2').play()"
    )
  ),tags$video(
    id = "video2",type = "mov",src = "Screen Recording 2021-05-25 at 4.03.51 AM.mov",controls = ""
  )
      
))

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。