don't show controls on videos until the mouse is moved over them

This commit is contained in:
ccd0 2014-07-26 23:15:16 -07:00
parent a8f4f419dd
commit b224d20896
5 changed files with 16 additions and 18 deletions

View File

@ -57,7 +57,9 @@ Main =
Redirect.navigate URL
else if Conf['Loop in New Tab'] and video = $ 'video'
video.loop = true
Video.start video
video.controls = false
video.play()
ImageCommon.addControls video
return
if Conf['Normalize URL'] and g.VIEW is 'thread'

View File

@ -160,8 +160,8 @@ Gallery =
$.replace nodes.current, file
if elType is 'video'
file.loop = true
file.controls = Conf['Show Controls']
Video.start file if Conf['Autoplay']
file.play() if Conf['Autoplay']
ImageCommon.addControls file if Conf['Show Controls']
nodes.count.textContent = +@dataset.id + 1
nodes.current = file
nodes.frame.scrollTop = 0
@ -216,7 +216,7 @@ Gallery =
Gallery.cb.cleanupTimer()
{current} = Gallery.nodes
isVideo = current.nodeName is 'VIDEO'
Video.start current if isVideo
current.play() if isVideo
if (if isVideo then current.readyState > 4 else current.complete) or current.nodeName is 'IFRAME'
Gallery.cb.startTimer()
else

View File

@ -42,3 +42,11 @@ ImageCommon =
filename: post.file.URL
if URL and (/^https:\/\//.test(URL) or location.protocol is 'http:')
return cb URL
addControls: (video) ->
handler = ->
$.off video, 'mouseover', handler
# Hacky workaround for Firefox forever-loading bug for very short videos
$.asap (-> (video.readyState >= 3 and video.currentTime <= Math.max 0.1, (video.duration - 0.5)) or !d.contains video), ->
video.controls = true
$.on video, 'mouseover', handler

View File

@ -171,9 +171,9 @@ ImageExpand =
video = file.fullImage
video.loop = true
video.controls = Conf['Show Controls']
ImageExpand.setupVideoCB post
ImageExpand.play post if Conf['Autoplay']
ImageCommon.addControls video if Conf['Show Controls']
# Scroll to keep our place in the thread when images are expanded above us.
if oldBottom? and oldBottom <= 0
@ -181,7 +181,7 @@ ImageExpand =
play: (post) ->
if !d.hidden and Header.isNodeVisible post.file.fullImage
Video.start post.file.fullImage
post.file.fullImage.play()
else
post.file.wasPlaying = true

View File

@ -1,12 +0,0 @@
Video =
start: (video) ->
return unless video.paused
{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 !d.contains video), ->
video.controls = true
, 500