R Shiny downloadButton error in Internet Explorer 8 - r

Running the following minimal case:
library(shiny)
runApp(list(
ui = bootstrapPage(downloadButton("myDownload")),
server = function(input, output) {
output$myDownload <- downloadHandler(
filename = function() "mtcars.txt",
content = function(file) write.table(mtcars, file),
contentType = ".txt"
)
}
))
which looks like:
yields the below error in Internet Explorer 8.0.7601 when I click the download button:
Anyone know why this is happening?

Cannot recreate the problem, since I do not have IE 8. But I have remembered this thread, which talks about incompatibilty of shiny with Internet explorer lower than 10:
shiny-discuss/websockets
So I would suggest you upgrade your browser (your code works on my Internet Explorer 10, for example.)

does your code works with other browser like firefox or chrome? Past i have faced similar problem in download data thing. in downloadHandaler where data is getting generated i have assigned it as a global variable. after that is started working, i guess.

Related

R Shiny: embed local video [duplicate]

I'm trying to get videos saved locally to play in RShiny but I only get an empty video player with no video loaded or way to load one. I've seen several posts on this when searched but none seem to reach an answer. My code is:
library(shiny)
ui <- fluidPage(
tags$video(src = "C:/Downloads/big_buck_bunny_720p_30mb.mp4", type
= "video/mp4", autoplay = TRUE, controls = TRUE)
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
This results in a mini player loading in RStudio browser or Edge but no video:
Screenshot
However, if I view source on the Edge page, save that as an .html file and load that file in Edge it works fine. It just doesn't work when run from RStudio as in Edge won't display videos when the address is of the form http://127.0.0.1:6190/. Any ideas? Security settings or something? RStudio plays the same video fine if I instead use a web URL rather than local video file as well.
I've tried loads of iterations of ui.r / server.r, files in www folder, etc. none of which work. Rstudio native browser has same behaviour as Edge (although it can't display the .html file either).
Thanks #ismirsehregal - this gets me a lot further. The video now plays but weirdly looks washed (greyed) out. If I select fullscreen the colour comes back fully. The actual video is https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_30mb.mp4 if that helps.
In RStudio I also get the message:
Listening on http://127.0.0.1:7109
Warning: Error in value[[3L]]: Couldn't normalize path in addResourcePath, with arguments: prefix = 'videos'; directoryPath = 'C:/Downloads'
55: stop
54: value[[3L]]
53: tryCatchOne
52: tryCatchList
51: tryCatch
50: addResourcePath
49: server [#2]
Error in value[3L] :
Couldn't normalize path in addResourcePath, with arguments: prefix = 'videos'; directoryPath = 'C:/Downloads'
but apart from the colour it works.
You can add static resources to Shiny's web server via addResourcePath.
Please try the following:
library(shiny)
ui <- fluidPage(
tags$video(src = "videos/big_buck_bunny_720p_30mb.mp4", type = "video/mp4", autoplay = TRUE, controls = TRUE)
)
server <- function(input, output, session) {
addResourcePath(prefix = "videos", directoryPath = "C:/Downloads")
}
shinyApp(ui, server)
However, using the www subdirectory should also be fine. The prefix for the www folder is "/". Please see this.

How Can I Set a Youtube Video to Autoplay Using R Shiny?

I'm using this code which will accept a Youtube URL and play the video in the RStudio viewer pane, rather than in a popout browser. It does exactly what I need it to do except that I would like it to autoplay when the function has run. I've seen a few other examples ( Like here and here ) where folks insert an allow = autoplay or something similar in the UI's fluidPage command but I haven't gotten it to work for me. I have additionally tried adding ?autoplay=1 to the URL, as described here, which works generally in any browser but seems to be ignored by R. Here's an example to replicate with:
videoplay <- function(url = "https://www.youtube.com/embed/wpHQnCaAJv8")
{
library(shiny)
xy <- c(784,479)
url <- gsub("watch\\?v=","embed/",url)
ui <- fluidPage(
HTML(paste0('<iframe width="',xy[1],'" height="',xy[2], '" src="', url,"?autoplay=1",'" frameborder="0"></iframe>'))
)
server <- function(input, output, session) {
}
runGadget(shinyApp(ui, server,options=c("launch.browser"=FALSE,"port"=1111)),port=1111,viewer = paneViewer())
}
Does anyone know how to make this video autoplay when the function is run? Appreciate any help!

Why does my download button activate twice in shiny app?

So I have a shiny app (https://github.com/tadeu95/BAGs) (http://tadeu-apps.shinyapps.io/bags) and I have several download buttons. Recently what has started to happen is that when I click the download button it activates two times and downloads the same file twice. The thing is that the app worked for almost a year without any problem.
I've tried on chrome, edge and mozzila and happens every time. I don't know what happened because I didn't touch the part of the code where the downloads are implemented.
One thing I've just discovered is that if instead of clicking the download button with the left button of the mouse, I click the right button and choose "open link in a new tab", it downloads the file correctly only once.
This is a short reproducible app, I advise that you give as input "ursidae" as it downloads the file pretty quickly:
library(bold)
library(readr)
library(shiny)
library(shinyWidgets)
grades2<-function(groups){
taxon9<-bold_seqspec(taxon=groups, format = "tsv")
}
ui <- fluidPage(textInputAddon(inputId="taxa2",addon=icon("search"),width="500px",label=tags$h5(tags$strong("Enter the name of the taxonomic group or groups separated by commas, without spaces:")),placeholder="Example: Carnivora,Ursidae,Artiodactyla,Soricomorpha"),downloadBttn("downloadData_2",size="sm","Download"))
server <- function(input, output) {
taxaInput_2 <- reactive({grades2(unlist(strsplit(input$taxa2, ",")))})
output$downloadData_2 <- downloadHandler(
filename = function() {
paste(input$taxa2,sep_out=",", ".tsv")
},
content = function(file) {
shiny::withProgress(
message=paste0("Downloading and annotating library for ",input$taxa2,sep_out=","), detail='This may take several minutes',
value=10,
{
shiny::incProgress(10/10)
write_tsv(taxaInput_2(), file)
}
)
}
)
}
shinyApp(ui=ui,server=server)
If anyone has any idea what the reason might be, I will be very thankful.

R shiny dynamically render audio [close]

I am working on a project, trying to render audio dynamically. That is, I can click a button and play a selected local audio.
I have read this post and tried zedii's trick. The problem remains still.
Well I build a test app as shown below.
library(shiny)
# test set ----
ui <- fluidPage(
textInput('my_music','path:',value="questionF"),
actionButton("ok", "Okay"),
uiOutput('my_audio')
# tags$audio(src = "questionF.mp3", type = "audio/mp3")
)
get_audio_tag <- function(filename) {
tags$audio(src = filename,
type = "audio/mp3",
controls = "controls")
}
server <- function(input, output, session){
# Render the audio player
observeEvent(input$ok, {
wav_name = input$my_music
# output$my_audio <-renderUI(get_audio_tag("questionF.mp3"))
output$my_audio <-renderUI(get_audio_tag(wav_name))
})
}
shinyApp(ui = ui, server = server)
When I click the button, the first song turns out okay. But the following ones seemed pretty hard to load, for my computer would freeze with the memory used by Rstudio rising.
Any thoughts will be appreciated.
updates:
I tried on different browsers. These codes would failed on Chrome but works fine on Microsoft edges.
Looks like a caching problem.
So now my question is how can I make the codes work on every platform using shiny/R?
My codes works on most browser other than Chrome. I think it's more like a Chrome's problem.

How do I get the R Shiny downloadHandler filename to work?

I am setting up a Shiny app that allows the user to download a custom dataset. Following the tutorial, I set up the downloadHandler following the example given in the docs (reproduced here, since the same thing happens if I copy and paste this).
ui <- fluidPage(
downloadLink("downloadData", "Download")
)
server <- function(input, output) {
# Our dataset
data <- mtcars
output$downloadData <- downloadHandler(
filename = function() {
paste("data-", Sys.Date(), ".csv", sep="")
},
content = function(file) {
write.csv(data, file)
}
)
}
shinyApp(ui, server)
Problem:
This issue only comes up on my Linux* system and seems to work just fine on a Mac. The download and everything works just fine, but the "Save" GUI does not offer me the right file name. There is no error message or warning. Based on my input,
I'd expect it to give me data-TIME.csv, i.e. the input to filename. (It does not work either if I give it simple string in that slot).
but it offers me DownloadData or whatever name I give to the output variable (cf. screenshot).
Question:
Is this a OS issue as I suspect, or am I doing something wrong?
How do i fix this? Can I get this to work on any system?
Thanks!
I'm running elementary OS 0.4 Loki, Built on "Ubuntu 16.04.2 LTS", GTK version: 3.18.9. & RStudio 1.0.143
If you are using the Rstudio Browser to test you App this could be the problem. I have the same issue on Windows.
When I use the Rstudio Browser the filename is not properly hand over, but if I use Firefox everything works fine. Your code works also fine in my Firefox.

Resources