Remember mute/volume settings of last video adjusted.
Also put mute/volume controls in the header menu.
This commit is contained in:
parent
160de415d2
commit
0fa2498d71
@ -247,7 +247,7 @@ Config =
|
|||||||
]
|
]
|
||||||
'Allow Sound': [
|
'Allow Sound': [
|
||||||
true
|
true
|
||||||
'Allow sound in videos.'
|
'Open videos with the sound unmuted.'
|
||||||
]
|
]
|
||||||
'Loop in New Tab': [
|
'Loop in New Tab': [
|
||||||
true
|
true
|
||||||
@ -560,6 +560,8 @@ Config =
|
|||||||
6.0
|
6.0
|
||||||
]
|
]
|
||||||
|
|
||||||
|
'Default Volume': 1.0
|
||||||
|
|
||||||
threadWatcher:
|
threadWatcher:
|
||||||
'Current Board': [
|
'Current Board': [
|
||||||
false
|
false
|
||||||
|
|||||||
@ -338,6 +338,7 @@ Main =
|
|||||||
['Reveal Spoiler Thumbnails', RevealSpoilers]
|
['Reveal Spoiler Thumbnails', RevealSpoilers]
|
||||||
['Image Loading', ImageLoader]
|
['Image Loading', ImageLoader]
|
||||||
['Image Hover', ImageHover]
|
['Image Hover', ImageHover]
|
||||||
|
['Volume Control', Volume]
|
||||||
['Comment Expansion', ExpandComment]
|
['Comment Expansion', ExpandComment]
|
||||||
['Thread Expansion', ExpandThread]
|
['Thread Expansion', ExpandThread]
|
||||||
['Thread Excerpt', ThreadExcerpt]
|
['Thread Excerpt', ThreadExcerpt]
|
||||||
|
|||||||
@ -928,6 +928,12 @@ span.hide-announcement {
|
|||||||
.fileThumb > .warning {
|
.fileThumb > .warning {
|
||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
|
input[name="Default Volume"] {
|
||||||
|
width: 4em;
|
||||||
|
height: 1ex;
|
||||||
|
vertical-align: middle;
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
/* Fappe Tyme */
|
/* Fappe Tyme */
|
||||||
:root.fappeTyme .thread > .noFile,
|
:root.fappeTyme .thread > .noFile,
|
||||||
:root.fappeTyme .threadContainer > .noFile {
|
:root.fappeTyme .threadContainer > .noFile {
|
||||||
|
|||||||
@ -156,7 +156,7 @@ Gallery =
|
|||||||
$.replace nodes.current, file
|
$.replace nodes.current, file
|
||||||
if elType is 'video'
|
if elType is 'video'
|
||||||
file.loop = true
|
file.loop = true
|
||||||
file.muted = !Conf['Allow Sound']
|
Volume.setup file
|
||||||
file.play() if Conf['Autoplay']
|
file.play() if Conf['Autoplay']
|
||||||
ImageCommon.addControls file if Conf['Show Controls']
|
ImageCommon.addControls file if Conf['Show Controls']
|
||||||
nodes.count.textContent = +thumb.dataset.id + 1
|
nodes.count.textContent = +thumb.dataset.id + 1
|
||||||
|
|||||||
@ -28,7 +28,7 @@ ImageExpand =
|
|||||||
ImageExpand.expand @
|
ImageExpand.expand @
|
||||||
|
|
||||||
else if @file.isExpanded and @file.isVideo
|
else if @file.isExpanded and @file.isVideo
|
||||||
@file.fullImage.muted = !Conf['Allow Sound']
|
Volume.setup @file.fullImage
|
||||||
ImageExpand.setupVideo @, !@origin.file.fullImage?.paused or @origin.file.wasPlaying, @file.fullImage.controls
|
ImageExpand.setupVideo @, !@origin.file.fullImage?.paused or @origin.file.wasPlaying, @file.fullImage.controls
|
||||||
|
|
||||||
else if ImageExpand.on and !@isHidden and !@isFetchedQuote and
|
else if ImageExpand.on and !@isHidden and !@isFetchedQuote and
|
||||||
@ -168,6 +168,7 @@ ImageExpand =
|
|||||||
ImageCommon.rewind el if Conf['Restart when Opened'] and el.id isnt 'ihover'
|
ImageCommon.rewind el if Conf['Restart when Opened'] and el.id isnt 'ihover'
|
||||||
el.removeAttribute 'id'
|
el.removeAttribute 'id'
|
||||||
else
|
else
|
||||||
|
isNew = true
|
||||||
el = file.fullImage = $.el (if isVideo then 'video' else 'img')
|
el = file.fullImage = $.el (if isVideo then 'video' else 'img')
|
||||||
el.dataset.fullID = post.fullID
|
el.dataset.fullID = post.fullID
|
||||||
$.on el, 'error', ImageExpand.error
|
$.on el, 'error', ImageExpand.error
|
||||||
@ -182,7 +183,7 @@ ImageExpand =
|
|||||||
thumb.parentNode.removeAttribute 'target'
|
thumb.parentNode.removeAttribute 'target'
|
||||||
|
|
||||||
el.loop = true
|
el.loop = true
|
||||||
el.muted = !Conf['Allow Sound']
|
Volume.setup el, isNew
|
||||||
|
|
||||||
if !isVideo
|
if !isVideo
|
||||||
$.asap (-> el.naturalHeight), -> ImageExpand.completeExpand post
|
$.asap (-> el.naturalHeight), -> ImageExpand.completeExpand post
|
||||||
|
|||||||
@ -29,6 +29,7 @@ ImageHover =
|
|||||||
el = ImageCommon.popCache()
|
el = ImageCommon.popCache()
|
||||||
$.on el, 'error', error
|
$.on el, 'error', error
|
||||||
else
|
else
|
||||||
|
isNew = true
|
||||||
el = $.el (if isVideo then 'video' else 'img')
|
el = $.el (if isVideo then 'video' else 'img')
|
||||||
el.dataset.fullID = post.fullID
|
el.dataset.fullID = post.fullID
|
||||||
$.on el, 'error', error
|
$.on el, 'error', error
|
||||||
@ -42,7 +43,7 @@ ImageHover =
|
|||||||
if isVideo
|
if isVideo
|
||||||
el.loop = true
|
el.loop = true
|
||||||
el.controls = false
|
el.controls = false
|
||||||
el.muted = !Conf['Allow Sound']
|
Volume.setup el, isNew
|
||||||
el.play() if Conf['Autoplay']
|
el.play() if Conf['Autoplay']
|
||||||
[width, height] = (+x for x in file.dimensions.split 'x')
|
[width, height] = (+x for x in file.dimensions.split 'x')
|
||||||
{left, right} = @getBoundingClientRect()
|
{left, right} = @getBoundingClientRect()
|
||||||
|
|||||||
42
src/Images/Volume.coffee
Normal file
42
src/Images/Volume.coffee
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
Volume =
|
||||||
|
init: ->
|
||||||
|
return unless g.BOARD.ID in ['gif', 'wsg'] and
|
||||||
|
g.VIEW in ['index', 'thread'] and
|
||||||
|
(Conf['Image Expansion'] or Conf['Image Hover'] or Conf['Image Hover in Catalog'] or Conf['Gallery'])
|
||||||
|
|
||||||
|
unmuteEntry = UI.checkbox 'Allow Sound', ' Allow Sound'
|
||||||
|
unmuteEntry.title = Config.main['Images and Videos']['Allow Sound'][1]
|
||||||
|
|
||||||
|
volumeEntry = $.el 'label',
|
||||||
|
title: 'Default volume for videos.'
|
||||||
|
$.extend volumeEntry,
|
||||||
|
<%= html('<input name="Default Volume" type="range" min="0" max="1" step="0.01" value="${Conf["Default Volume"]}"> Volume') %>
|
||||||
|
|
||||||
|
@inputs =
|
||||||
|
unmute: unmuteEntry.firstElementChild
|
||||||
|
volume: volumeEntry.firstElementChild
|
||||||
|
|
||||||
|
$.on @inputs.unmute, 'change', $.cb.checked
|
||||||
|
$.on @inputs.volume, 'change', $.cb.value
|
||||||
|
|
||||||
|
$.sync 'Allow Sound', (x) -> Volume.inputs.unmute.checked = x
|
||||||
|
$.sync 'Default Volume', (x) -> Volume.inputs.volume.value = x
|
||||||
|
|
||||||
|
Header.menu.addEntry {el: unmuteEntry, order: 200}
|
||||||
|
Header.menu.addEntry {el: volumeEntry, order: 201}
|
||||||
|
|
||||||
|
setup: (video, isNew=true) ->
|
||||||
|
video.muted = !Conf['Allow Sound']
|
||||||
|
video.volume = Conf['Default Volume']
|
||||||
|
$.on video, 'volumechange', Volume.onchange if isNew
|
||||||
|
|
||||||
|
onchange: ->
|
||||||
|
{muted, volume} = @
|
||||||
|
items =
|
||||||
|
'Allow Sound': !muted
|
||||||
|
'Default Volume': volume
|
||||||
|
$.set items
|
||||||
|
$.extend Conf, items
|
||||||
|
if Volume.inputs
|
||||||
|
Volume.inputs.unmute.checked = !muted
|
||||||
|
Volume.inputs.volume.value = volume
|
||||||
Loading…
x
Reference in New Issue
Block a user