play clone if original is playing

This commit is contained in:
ccd0 2014-04-07 20:27:42 -07:00
parent fe1b68a635
commit bf09a5d008
3 changed files with 72 additions and 54 deletions

View File

@ -7596,7 +7596,7 @@
});
},
node: function() {
var thumb, _ref, _ref1;
var clone, thumb, _ref, _ref1;
if (!(((_ref = this.file) != null ? _ref.isImage : void 0) || ((_ref1 = this.file) != null ? _ref1.isVideo : void 0))) {
return;
}
@ -7606,7 +7606,13 @@
ImageExpand.contract(this);
return ImageExpand.expand(this);
} else if (this.isClone && this.file.isExpanded && this.file.isVideo) {
return ImageExpand.setupVideoControls(this);
clone = this;
ImageExpand.setupVideoControls(clone);
if (!clone.origin.file.fullImage.paused) {
return $.queueTask(function() {
return ImageExpand.startVideo(clone);
});
}
} else if (ImageExpand.on && !this.isHidden && (Conf['Expand spoilers'] || !this.file.isSpoiler)) {
return ImageExpand.expand(this);
}
@ -7772,7 +7778,12 @@
$.rmClass(post.file.thumb, 'expanding');
post.file.isExpanded = true;
if (post.file.isVideo) {
return ImageExpand.setupVideo(post);
ImageExpand.setupVideoControls(post);
post.file.fullImage.muted = !Conf['Allow Sound'];
post.file.fullImage.controls = Conf['Show Controls'];
if (Conf['Autoplay']) {
return ImageExpand.startVideo(post);
}
}
},
videoCB: {
@ -7829,25 +7840,21 @@
}
return $.add(file.text, file.videoControls);
},
setupVideo: function(post) {
var file, video;
ImageExpand.setupVideoControls(post);
startVideo: function(post) {
var controls, file, video;
file = post.file;
video = file.fullImage;
video.muted = !Conf['Allow Sound'];
video.controls = Conf['Show Controls'];
if (Conf['Autoplay']) {
video.controls = false;
video.play();
if (Conf['Show Controls']) {
return $.asap((function() {
return (video.readyState >= 3 && video.currentTime <= Math.max(0.1, video.duration - 0.5)) || !file.isExpanded;
}), function() {
if (file.isExpanded) {
return video.controls = true;
}
}, 500);
}
controls = video.controls;
video.controls = false;
video.play();
if (controls) {
return $.asap((function() {
return (video.readyState >= 3 && video.currentTime <= Math.max(0.1, video.duration - 0.5)) || !file.isExpanded;
}), function() {
if (file.isExpanded) {
return video.controls = true;
}
}, 500);
}
},
error: function() {

View File

@ -7615,7 +7615,7 @@
});
},
node: function() {
var thumb, _ref, _ref1;
var clone, thumb, _ref, _ref1;
if (!(((_ref = this.file) != null ? _ref.isImage : void 0) || ((_ref1 = this.file) != null ? _ref1.isVideo : void 0))) {
return;
}
@ -7625,7 +7625,13 @@
ImageExpand.contract(this);
return ImageExpand.expand(this);
} else if (this.isClone && this.file.isExpanded && this.file.isVideo) {
return ImageExpand.setupVideoControls(this);
clone = this;
ImageExpand.setupVideoControls(clone);
if (!clone.origin.file.fullImage.paused) {
return $.queueTask(function() {
return ImageExpand.startVideo(clone);
});
}
} else if (ImageExpand.on && !this.isHidden && (Conf['Expand spoilers'] || !this.file.isSpoiler)) {
return ImageExpand.expand(this);
}
@ -7791,7 +7797,12 @@
$.rmClass(post.file.thumb, 'expanding');
post.file.isExpanded = true;
if (post.file.isVideo) {
return ImageExpand.setupVideo(post);
ImageExpand.setupVideoControls(post);
post.file.fullImage.muted = !Conf['Allow Sound'];
post.file.fullImage.controls = Conf['Show Controls'];
if (Conf['Autoplay']) {
return ImageExpand.startVideo(post);
}
}
},
videoCB: {
@ -7848,25 +7859,21 @@
}
return $.add(file.text, file.videoControls);
},
setupVideo: function(post) {
var file, video;
ImageExpand.setupVideoControls(post);
startVideo: function(post) {
var controls, file, video;
file = post.file;
video = file.fullImage;
video.muted = !Conf['Allow Sound'];
video.controls = Conf['Show Controls'];
if (Conf['Autoplay']) {
video.controls = false;
video.play();
if (Conf['Show Controls']) {
return $.asap((function() {
return (video.readyState >= 3 && video.currentTime <= Math.max(0.1, video.duration - 0.5)) || !file.isExpanded;
}), function() {
if (file.isExpanded) {
return video.controls = true;
}
}, 500);
}
controls = video.controls;
video.controls = false;
video.play();
if (controls) {
return $.asap((function() {
return (video.readyState >= 3 && video.currentTime <= Math.max(0.1, video.duration - 0.5)) || !file.isExpanded;
}), function() {
if (file.isExpanded) {
return video.controls = true;
}
}, 500);
}
},
error: function() {

View File

@ -23,7 +23,10 @@ ImageExpand =
ImageExpand.contract @
ImageExpand.expand @
else if @isClone and @file.isExpanded and @file.isVideo
ImageExpand.setupVideoControls @
clone = @
ImageExpand.setupVideoControls clone
unless clone.origin.file.fullImage.paused
$.queueTask -> ImageExpand.startVideo clone
else if ImageExpand.on and !@isHidden and (Conf['Expand spoilers'] or !@file.isSpoiler)
ImageExpand.expand @
cb:
@ -143,7 +146,11 @@ ImageExpand =
$.addClass post.nodes.root, 'expanded-image'
$.rmClass post.file.thumb, 'expanding'
post.file.isExpanded = true
ImageExpand.setupVideo post if post.file.isVideo
if post.file.isVideo
ImageExpand.setupVideoControls post
post.file.fullImage.muted = !Conf['Allow Sound']
post.file.fullImage.controls = Conf['Show Controls']
ImageExpand.startVideo post if Conf['Autoplay']
videoCB:
click: (e) ->
@ -183,20 +190,17 @@ ImageExpand =
$.add file.videoControls, [$.tn('\u00A0'), contract]
$.add file.text, file.videoControls
setupVideo: (post) ->
ImageExpand.setupVideoControls post
startVideo: (post) ->
{file} = post
video = file.fullImage
video.muted = !Conf['Allow Sound']
video.controls = Conf['Show Controls']
if Conf['Autoplay']
video.controls = false
video.play()
# Hacky workaround for Firefox forever-loading bug for very short videos
if Conf['Show Controls']
$.asap (-> (video.readyState >= 3 and video.currentTime <= Math.max 0.1, (video.duration - 0.5)) or !file.isExpanded), ->
video.controls = true if file.isExpanded
, 500
{controls} = video
video.controls = false
video.play()
# Hacky workaround for Firefox forever-loading bug for very short videos
if controls
$.asap (-> (video.readyState >= 3 and video.currentTime <= Math.max 0.1, (video.duration - 0.5)) or !file.isExpanded), ->
video.controls = true if file.isExpanded
, 500
error: ->
post = Get.postFromNode @