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': [
|
||||
true
|
||||
'Allow sound in videos.'
|
||||
'Open videos with the sound unmuted.'
|
||||
]
|
||||
'Loop in New Tab': [
|
||||
true
|
||||
@ -560,6 +560,8 @@ Config =
|
||||
6.0
|
||||
]
|
||||
|
||||
'Default Volume': 1.0
|
||||
|
||||
threadWatcher:
|
||||
'Current Board': [
|
||||
false
|
||||
|
||||
@ -338,6 +338,7 @@ Main =
|
||||
['Reveal Spoiler Thumbnails', RevealSpoilers]
|
||||
['Image Loading', ImageLoader]
|
||||
['Image Hover', ImageHover]
|
||||
['Volume Control', Volume]
|
||||
['Comment Expansion', ExpandComment]
|
||||
['Thread Expansion', ExpandThread]
|
||||
['Thread Excerpt', ThreadExcerpt]
|
||||
|
||||
@ -928,6 +928,12 @@ span.hide-announcement {
|
||||
.fileThumb > .warning {
|
||||
clear: both;
|
||||
}
|
||||
input[name="Default Volume"] {
|
||||
width: 4em;
|
||||
height: 1ex;
|
||||
vertical-align: middle;
|
||||
margin: 0px;
|
||||
}
|
||||
/* Fappe Tyme */
|
||||
:root.fappeTyme .thread > .noFile,
|
||||
:root.fappeTyme .threadContainer > .noFile {
|
||||
|
||||
@ -156,7 +156,7 @@ Gallery =
|
||||
$.replace nodes.current, file
|
||||
if elType is 'video'
|
||||
file.loop = true
|
||||
file.muted = !Conf['Allow Sound']
|
||||
Volume.setup file
|
||||
file.play() if Conf['Autoplay']
|
||||
ImageCommon.addControls file if Conf['Show Controls']
|
||||
nodes.count.textContent = +thumb.dataset.id + 1
|
||||
|
||||
@ -28,7 +28,7 @@ ImageExpand =
|
||||
ImageExpand.expand @
|
||||
|
||||
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
|
||||
|
||||
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'
|
||||
el.removeAttribute 'id'
|
||||
else
|
||||
isNew = true
|
||||
el = file.fullImage = $.el (if isVideo then 'video' else 'img')
|
||||
el.dataset.fullID = post.fullID
|
||||
$.on el, 'error', ImageExpand.error
|
||||
@ -182,7 +183,7 @@ ImageExpand =
|
||||
thumb.parentNode.removeAttribute 'target'
|
||||
|
||||
el.loop = true
|
||||
el.muted = !Conf['Allow Sound']
|
||||
Volume.setup el, isNew
|
||||
|
||||
if !isVideo
|
||||
$.asap (-> el.naturalHeight), -> ImageExpand.completeExpand post
|
||||
|
||||
@ -29,6 +29,7 @@ ImageHover =
|
||||
el = ImageCommon.popCache()
|
||||
$.on el, 'error', error
|
||||
else
|
||||
isNew = true
|
||||
el = $.el (if isVideo then 'video' else 'img')
|
||||
el.dataset.fullID = post.fullID
|
||||
$.on el, 'error', error
|
||||
@ -42,7 +43,7 @@ ImageHover =
|
||||
if isVideo
|
||||
el.loop = true
|
||||
el.controls = false
|
||||
el.muted = !Conf['Allow Sound']
|
||||
Volume.setup el, isNew
|
||||
el.play() if Conf['Autoplay']
|
||||
[width, height] = (+x for x in file.dimensions.split 'x')
|
||||
{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