Handle webm playback errors with image expansion.

Conflicts:
	CHANGELOG.md
	src/Images/ImageExpand.coffee
This commit is contained in:
Mayhem 2014-04-09 10:04:51 +02:00 committed by ccd0
parent e49f324465
commit aca6f22608

View File

@ -18,6 +18,8 @@ ImageExpand =
{thumb} = @file {thumb} = @file
$.on thumb.parentNode, 'click', ImageExpand.cb.toggle $.on thumb.parentNode, 'click', ImageExpand.cb.toggle
if @isClone if @isClone
if @file.error
@file.error = $ '.warning', @file.thumb.parentNode
if $.hasClass thumb, 'expanding' if $.hasClass thumb, 'expanding'
# If we clone a post where the image is still loading, # If we clone a post where the image is still loading,
# make it loading in the clone too. # make it loading in the clone too.
@ -113,7 +115,7 @@ ImageExpand =
delete post.file.videoControls delete post.file.videoControls
$.rmClass post.nodes.root, 'expanded-image' $.rmClass post.nodes.root, 'expanded-image'
$.rmClass thumb, 'expanding' $.rmClass thumb, 'expanding'
post.file.isExpanded = false delete post.file.isExpanded
expand: (post, src, disableAutoplay) -> expand: (post, src, disableAutoplay) ->
# Do not expand images of hidden/filtered replies, or already expanded pictures. # Do not expand images of hidden/filtered replies, or already expanded pictures.
@ -131,6 +133,9 @@ ImageExpand =
$.after thumb, el unless el is thumb.nextSibling $.after thumb, el unless el is thumb.nextSibling
$.asap (-> el.videoHeight or el.naturalHeight), -> $.asap (-> el.videoHeight or el.naturalHeight), ->
ImageExpand.completeExpand post, disableAutoplay ImageExpand.completeExpand post, disableAutoplay
if post.file.error
$.rm post.file.error
delete post.file.error
completeExpand: (post, disableAutoplay) -> completeExpand: (post, disableAutoplay) ->
return unless $.hasClass post.file.thumb, 'expanding' # contracted before the image loaded return unless $.hasClass post.file.thumb, 'expanding' # contracted before the image loaded
@ -196,10 +201,22 @@ ImageExpand =
# - before the image started loading. # - before the image started loading.
# - after the image started loading. # - after the image started loading.
unless $.hasClass(post.file.thumb, 'expanding') or $.hasClass post.nodes.root, 'expanded-image' unless $.hasClass(post.file.thumb, 'expanding') or $.hasClass post.nodes.root, 'expanded-image'
# Don't try to re-expend if it was already contracted. # Don't try to re-expand if it was already contracted.
return return
ImageExpand.contract post ImageExpand.contract post
if @error and @error.code isnt @error.MEDIA_ERR_NETWORK # video
error = switch @error.code
when 1 then 'MEDIA_ERR_ABORTED'
when 3 then 'MEDIA_ERR_DECODE'
when 4 then 'MEDIA_ERR_SRC_NOT_SUPPORTED'
when 5 then 'MEDIA_ERR_ENCRYPTED'
post.file.error = $.el 'div',
textContent: "Playback error: #{error}"
className: 'warning'
$.after post.file.thumb, post.file.error
return
src = @src.split '/' src = @src.split '/'
if src[2] is 'i.4cdn.org' if src[2] is 'i.4cdn.org'
URL = Redirect.to 'file', URL = Redirect.to 'file',