【问题标题】:Use actionButton() to play video inside modal dialog of a shiny dashboard使用 actionButton() 在闪亮仪表板的模态对话框中播放视频
【发布时间】:2021-05-26 00:37:48
【问题描述】:

我在下面有一个闪亮的仪表板,其中包括一个 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",title="Using the range slider",actionButton("play","",icon = icon("play"),style='padding:10px; font-size:80%')),
    
          #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)

【问题讨论】:

    标签: r shiny shinydashboard


    【解决方案1】:

    试试这个:

    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 = ""
      )
          
    ))
    

    【讨论】:

    • 对你有影响吗?之前按下按钮视频被隐藏
    猜你喜欢
    • 2021-12-14
    • 2018-01-22
    • 2015-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-05
    • 1970-01-01
    相关资源
    最近更新 更多