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