configure videos opened in new tab
This commit is contained in:
parent
1419d5f454
commit
ff057d4f29
@ -193,15 +193,19 @@ Config =
|
||||
]
|
||||
'Autoplay': [
|
||||
true
|
||||
'Videos begin playing immediately when opened inline.'
|
||||
'Videos begin playing immediately when opened.'
|
||||
]
|
||||
'Show Controls': [
|
||||
true
|
||||
'Show native seek and volume controls on videos. Contract videos when dragged to the left.'
|
||||
'Show controls on videos expanded inline. Turn this off if you want to contract videos by clicking on them.'
|
||||
]
|
||||
'Allow Sound': [
|
||||
true
|
||||
'Allow sound in inline videos.'
|
||||
'Allow sound in videos.'
|
||||
]
|
||||
'Loop in New Tab': [
|
||||
true
|
||||
'Loop videos opened in their own tabs, and apply settings for inline expanded videos to them.'
|
||||
]
|
||||
|
||||
'Menu':
|
||||
|
||||
@ -47,6 +47,11 @@ Main =
|
||||
Report.init()
|
||||
return
|
||||
when 'i.4cdn.org'
|
||||
if Conf['Loop in New Tab'] and video = $ 'video'
|
||||
Video.configure video
|
||||
$.on video, 'click', ->
|
||||
if !video.controls
|
||||
if video.paused then video.play() else video.pause()
|
||||
$.ready ->
|
||||
if Conf['404 Redirect'] and d.title in ['4chan - Temporarily Offline', '4chan - 404 Not Found']
|
||||
Redirect.init()
|
||||
|
||||
@ -26,7 +26,7 @@ ImageExpand =
|
||||
clone = @
|
||||
ImageExpand.setupVideoControls clone
|
||||
unless clone.origin.file.fullImage.paused
|
||||
$.queueTask -> ImageExpand.startVideo clone
|
||||
$.queueTask -> Video.start clone.file.fullImage
|
||||
else if ImageExpand.on and !@isHidden and
|
||||
(Conf['Expand spoilers'] or !@file.isSpoiler) and
|
||||
(Conf['Expand videos'] or !@file.isVideo)
|
||||
@ -123,7 +123,6 @@ ImageExpand =
|
||||
else
|
||||
el = post.file.fullImage = $.el (if isVideo then 'video' else 'img'),
|
||||
className: 'full-image'
|
||||
el.loop = true if isVideo
|
||||
$.on el, 'error', ImageExpand.error
|
||||
el.src = src or post.file.URL
|
||||
$.after thumb, el unless el is thumb.nextSibling
|
||||
@ -151,9 +150,7 @@ ImageExpand =
|
||||
post.file.isExpanded = true
|
||||
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'] and not disableAutoplay
|
||||
Video.configure post.file.fullImage, disableAutoplay
|
||||
|
||||
videoCB:
|
||||
click: (e) ->
|
||||
@ -193,18 +190,6 @@ ImageExpand =
|
||||
$.add file.videoControls, [$.tn('\u00A0'), contract]
|
||||
$.add file.text, file.videoControls
|
||||
|
||||
startVideo: (post) ->
|
||||
{file} = post
|
||||
video = file.fullImage
|
||||
{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 @
|
||||
$.rm @
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user