r - R flexdashboard:如何在文件路径中嵌入具有反应值的视频?
问题描述
我有一个flexdashboard,我需要嵌入一些视频。
使用静态文件路径,它非常简单:
tags$video(
src = "sample.mp4",
type = "video/mp4",
width = 1280, height = 720,
controls = "controls"
)
但我不知道如何使用包含输入/反应值的文件路径嵌入视频。这不起作用:
renderUI({
req(rv())
tags$video(
src = rv(),
type = "video/mp4",
width = 1280, height = 720,
controls = "controls"
)
})
这是一个包含两个示例的 Rmd 文件:
---
title: "Test"
output:
flexdashboard::flex_dashboard:
runtime: shiny
---
```{r setup}
library(flexdashboard)
library(shiny)
```
Column
------
### Static
```{r}
tags$video(
src = "sample.mp4",
type = "video/mp4",
width = 1280, height = 720,
controls = "controls"
)
```
Column
------
```{r}
rv <- reactive({ "sample.mp4" })
```
### Reactive
```{r}
renderUI({
req(rv())
tags$video(
src = rv(),
type = "video/mp4",
width = 1280, height = 720,
controls = "controls"
)
})
```
经检查,“静态”块生成以下 HTML:
<video src="file5450741f3ada_files/sample.mp4" type="video/mp4" width="1280" height="720" controls="controls"></video>
“动态”块在哪里:
<video src="sample.mp4" type="video/mp4" width="1280" height="720" controls="controls"></video>
看起来像是将文件放在一个临时文件夹中,当参数是反应值和/或 insidetags$video
时,不会发生这种情况。src
renderUI
有小费吗?
解决方案
推荐阅读
- javascript - JQuery 无法分配给“#back”上的属性“guid”:不是对象
- javascript - 如何验证用户是否点击了联系表格 7 提交后发送的验证链接?
- java - Java BasicDataSource 连接时卡住
- sql - 如何将此“2021 年 6 月 28 日 10:52:16 CDT (GMT-0500)”转换为 2021 年 6 月 28 日
- flutter - Riverpod - 以更好/优雅的方式创建具有异步依赖的服务
- javascript - 如何在 Typescript 的回调中访问类变量/方法?
- reactjs - 如何在子组件中传递道具以使用打字稿做出本机反应
- java - 来自具有 API 30 (android 11) 的三星物理模拟器的错误 Android 11 -> java.net.SocketTimeoutException
- javascript - 重命名所有键的对象JS
- javascript - 有没有办法让代码执行暂停 1 毫秒?我现在能做的最好是5ms左右