Merge pull request #2243 from antoine-levitt/fix_animated_gif
Alternative fix for #2239
This commit is contained in:
commit
c8b75dfae1
@ -21,9 +21,9 @@ function frame(anim::Animation, plt::P=current()) where P<:AbstractPlot
|
|||||||
push!(anim.frames, filename)
|
push!(anim.frames, filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
giffn() = (isijulia() ? "tmp_"*randstring()*".gif" : tempname()*".gif")
|
giffn() = (isijulia() ? "tmp.gif" : tempname()*".gif")
|
||||||
movfn() = (isijulia() ? "tmp_"*randstring()*".mov" : tempname()*".mov")
|
movfn() = (isijulia() ? "tmp.mov" : tempname()*".mov")
|
||||||
mp4fn() = (isijulia() ? "tmp_"*randstring()*".mp4" : tempname()*".mp4")
|
mp4fn() = (isijulia() ? "tmp.mp4" : tempname()*".mp4")
|
||||||
|
|
||||||
mutable struct FrameIterator
|
mutable struct FrameIterator
|
||||||
itr
|
itr
|
||||||
@ -104,13 +104,18 @@ end
|
|||||||
# write out html to view the gif
|
# write out html to view the gif
|
||||||
function Base.show(io::IO, ::MIME"text/html", agif::AnimatedGif)
|
function Base.show(io::IO, ::MIME"text/html", agif::AnimatedGif)
|
||||||
ext = file_extension(agif.filename)
|
ext = file_extension(agif.filename)
|
||||||
write(io, if ext == "gif"
|
if ext == "gif"
|
||||||
"<img src=\"$(relpath(agif.filename))\" />"
|
html = "<img src=\"data:image/gif;base64," * base64encode(read(agif.filename)) * "\" />"
|
||||||
elseif ext in ("mov", "mp4")
|
elseif ext in ("mov", "mp4")
|
||||||
"<video controls><source src=\"$(relpath(agif.filename))\" type=\"video/$ext\"></video>"
|
mimetype = ext == "mov" ? "video/quicktime" : "video/mp4"
|
||||||
|
html = "<video controls><source src=\"data:$mimetype;base64," *
|
||||||
|
base64encode(read(agif.filename)) *
|
||||||
|
"\" type = \"$mimetype\"></video>"
|
||||||
else
|
else
|
||||||
error("Cannot show animation with extension $ext: $agif")
|
error("Cannot show animation with extension $ext: $agif")
|
||||||
end)
|
end
|
||||||
|
|
||||||
|
write(io, html)
|
||||||
return nothing
|
return nothing
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user