From a85d5b23358a69e23a86ad619629db3a68123b44 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 31 Jan 2015 11:48:28 -0800 Subject: [PATCH] Don't pause WebMs with audio when off screen. --- src/General/lib/$.coffee | 3 +++ src/Images/ImageExpand.coffee | 1 + src/Posting/QR.coffee | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/General/lib/$.coffee b/src/General/lib/$.coffee index 99c85c940..a243439dd 100755 --- a/src/General/lib/$.coffee +++ b/src/General/lib/$.coffee @@ -296,6 +296,9 @@ $.minmax = (value, min, max) -> value ) +$.hasAudio = (video) -> + video.mozHasAudio or !!video.webkitAudioDecodedByteCount + $.item = (key, val) -> item = {} item[key] = val diff --git a/src/Images/ImageExpand.coffee b/src/Images/ImageExpand.coffee index 02cc24b35..6a228a48b 100755 --- a/src/Images/ImageExpand.coffee +++ b/src/Images/ImageExpand.coffee @@ -76,6 +76,7 @@ ImageExpand = g.posts.forEach (post) -> for post in [post, post.clones...] when post.file and post.file.isVideo and post.file.isExpanded video = post.file.fullImage + continue if $.hasAudio video visible = Header.isNodeVisible video if visible and post.file.wasPlaying delete post.file.wasPlaying diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 0066caa4d..5f3676496 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -404,7 +404,7 @@ QR = else if duration > QR.max_duration_video QR.error "#{file.name}: Video too long (video: #{duration}s, max: #{QR.max_duration_video}s)" pass = false - if g.BOARD.ID not in ['gif', 'wsg'] and (video.mozHasAudio or video.webkitAudioDecodedByteCount) + if g.BOARD.ID not in ['gif', 'wsg'] and $.hasAudio video QR.error "#{file.name}: Audio not allowed" pass = false cb pass, video