From 25313f6b4351308e77120e136802a82e98763f31 Mon Sep 17 00:00:00 2001 From: Antoine Levitt Date: Sat, 9 Nov 2019 16:49:48 +0100 Subject: [PATCH 1/4] Alternative fix for #2239 --- src/animation.jl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/animation.jl b/src/animation.jl index d05c92e3..659353e5 100644 --- a/src/animation.jl +++ b/src/animation.jl @@ -21,9 +21,9 @@ function frame(anim::Animation, plt::P=current()) where P<:AbstractPlot push!(anim.frames, filename) end -giffn() = (isijulia() ? "tmp_"*randstring()*".gif" : tempname()*".gif") -movfn() = (isijulia() ? "tmp_"*randstring()*".mov" : tempname()*".mov") -mp4fn() = (isijulia() ? "tmp_"*randstring()*".mp4" : tempname()*".mp4") +giffn() = (isijulia() ? "tmp.gif" : tempname()*".gif") +movfn() = (isijulia() ? "tmp.mov" : tempname()*".mov") +mp4fn() = (isijulia() ? "tmp.mp4" : tempname()*".mp4") mutable struct FrameIterator itr @@ -104,10 +104,12 @@ end # write out html to view the gif function Base.show(io::IO, ::MIME"text/html", agif::AnimatedGif) ext = file_extension(agif.filename) + link = relpath(agif.filename) + link *= "?"*randstring() #to foil browser cache, see https://github.com/JuliaPlots/Plots.jl/issues/2239 write(io, if ext == "gif" - "" + "" elseif ext in ("mov", "mp4") - "" + "" else error("Cannot show animation with extension $ext: $agif") end) From cb4702f7b82afe62b3eea52c54ad667f0ca1b77a Mon Sep 17 00:00:00 2001 From: Antoine Levitt Date: Mon, 11 Nov 2019 10:49:55 +0100 Subject: [PATCH 2/4] Embed gifs and videos --- src/animation.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/animation.jl b/src/animation.jl index 659353e5..e4a213ce 100644 --- a/src/animation.jl +++ b/src/animation.jl @@ -104,12 +104,12 @@ end # write out html to view the gif function Base.show(io::IO, ::MIME"text/html", agif::AnimatedGif) ext = file_extension(agif.filename) - link = relpath(agif.filename) - link *= "?"*randstring() #to foil browser cache, see https://github.com/JuliaPlots/Plots.jl/issues/2239 write(io, if ext == "gif" - "" + "" elseif ext in ("mov", "mp4") - "" + "" else error("Cannot show animation with extension $ext: $agif") end) From 3db930cb9386680879a9e1b8e744435757a41c80 Mon Sep 17 00:00:00 2001 From: Antoine Levitt Date: Tue, 12 Nov 2019 19:06:36 +0100 Subject: [PATCH 3/4] correct mimetype for mov --- src/animation.jl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/animation.jl b/src/animation.jl index e4a213ce..63e001d0 100644 --- a/src/animation.jl +++ b/src/animation.jl @@ -104,15 +104,18 @@ end # write out html to view the gif function Base.show(io::IO, ::MIME"text/html", agif::AnimatedGif) ext = file_extension(agif.filename) - write(io, if ext == "gif" - "" + if ext == "gif" + html = "" elseif ext in ("mov", "mp4") - "" + mimetype = ext == "mov" ? "video/quicktime" : "video/mp4" + html = "" else error("Cannot show animation with extension $ext: $agif") - end) + end + + write(io, html) return nothing end From 94812cde7afb3f3fe2caf7a07b593832b84e7a1c Mon Sep 17 00:00:00 2001 From: Antoine Levitt Date: Tue, 12 Nov 2019 19:31:55 +0100 Subject: [PATCH 4/4] fix mimetype again --- src/animation.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/animation.jl b/src/animation.jl index 63e001d0..7e5f9a8e 100644 --- a/src/animation.jl +++ b/src/animation.jl @@ -110,7 +110,7 @@ function Base.show(io::IO, ::MIME"text/html", agif::AnimatedGif) mimetype = ext == "mov" ? "video/quicktime" : "video/mp4" html = "" + "\" type = \"$mimetype\">" else error("Cannot show animation with extension $ext: $agif") end