【问题标题】:Taking screenshot in Shiny App in R not working在 R 中的 Shiny App 中截屏不起作用
【发布时间】:2022-01-18 15:39:16
【问题描述】:

我正在尝试截取我闪亮的应用程序的屏幕截图。

当我只有情节时,一切都很好。但是当我添加视频时,它就无法正常工作。我的情节还可以,但视频区是空的。

这是我的代码:

library(shiny)
library(tidyverse)
library(shinyscreenshot)

ui <- fluidPage(
  actionButton("go","Go"),
div(
  plotOutput("plot1"),
  tags$iframe(id = "video",width="560", height="315", src="https://www.youtube.com/embed/T1-k7VYwsHg", frameborder="0", allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",
              allowfullscreen=NA),
  plotOutput("plot2")
)


)

server <- function(input, output, session) {

  output$plot1 <- renderPlot({

    ggplot(mtcars, aes(mpg,cyl)) + geom_point()

  })
  output$plot2 <- renderPlot({

    ggplot(mtcars, aes(mpg,cyl)) + geom_point()

  })

observeEvent(input$go, {
  shinyscreenshot::screenshot(id = "video")
  })
}

shinyApp(ui, server)

有什么帮助吗?

是因为 iframe 吗?

我该如何解决这个问题??

非常感谢

【问题讨论】:

    标签: r shiny shinyscreenshot


    【解决方案1】:

    shinyscreenshot 基于 html2canvas JavaScript 库。

    提到了 html2canvas 的一个限制here

    脚本使用的所有图像都需要位于same origin 下,这样它才能在没有帮助的情况下读取它们 proxy.

    除非您愿意设置代理服务器,否则此限制适用于 iframe。

    但是,一般视频似乎是an issue

    您可以尝试截屏另一个隐藏的 html 标记,而不是按照 here 的建议。

    【讨论】:

      猜你喜欢
      • 2020-04-26
      • 2018-08-20
      • 1970-01-01
      • 2021-01-29
      • 1970-01-01
      • 1970-01-01
      • 2020-07-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多