From 0ef2db58ea210ab435051f4c17778c12b62416ec Mon Sep 17 00:00:00 2001 From: ccd0 Date: Tue, 4 Mar 2014 16:45:53 -0800 Subject: [PATCH] mute -> volume control --- expandvideo.js | 6 ++++-- playersettings.js | 3 ++- settings.js | 24 ++++++++++++++++-------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/expandvideo.js b/expandvideo.js index fb18fac8..771a5936 100644 --- a/expandvideo.js +++ b/expandvideo.js @@ -84,7 +84,8 @@ function setupVideo(thumb, url) { videoContainer.style.position = "static"; thumb.style.display = "none"; - video.muted = setting("videomuted"); + video.muted = (setting("videovolume") == 0); + video.volume = setting("videovolume"); video.controls = true; if (video.readyState == 0) { video.addEventListener("loadedmetadata", expand2, false); @@ -130,7 +131,8 @@ function setupVideo(thumb, url) { videoContainer.style.display = "inline"; videoContainer.style.position = "fixed"; - video.muted = setting("videomuted"); + video.muted = (setting("videovolume") == 0); + video.volume = setting("videovolume"); video.controls = false; video.play(); } diff --git a/playersettings.js b/playersettings.js index 26242586..8d9a8d20 100644 --- a/playersettings.js +++ b/playersettings.js @@ -21,6 +21,7 @@ if (window.addEventListener) window.addEventListener("load", function(e) { setupLoopLink(i); } - video.muted = setting("videomuted"); + video.muted = (setting("videovolume") == 0); + video.volume = setting("videovolume"); video.play(); }, false); diff --git a/settings.js b/settings.js index 0d7a494b..cc4a30d5 100644 --- a/settings.js +++ b/settings.js @@ -11,7 +11,7 @@ function setDefault(name, value) { } setDefault("videoexpand", true); setDefault("videohover", false); -setDefault("videomuted", false); +setDefault("videovolume", 1.0); // Create settings menu var settingsMenu = document.createElement("span"); @@ -20,27 +20,35 @@ settingsMenu.innerHTML = '[Settings]' + '
' + '
' + '
' - + '
' + + '
' + '
'; function refreshSettings() { var settingsItems = settingsMenu.getElementsByTagName("input"); for (var i = 0; i < settingsItems.length; i++) { - var box = settingsItems[i]; - box.checked = setting(box.name); + var control = settingsItems[i]; + if (control.type == "checkbox") { + control.checked = setting(control.name); + } else if (control.type == "range") { + control.value = setting(control.name); + } } } -function setupCheckbox(box) { - if (box.addEventListener) box.addEventListener("change", function(e) { - localStorage[box.name] = JSON.stringify(box.checked); +function setupControl(control) { + if (control.addEventListener) control.addEventListener("change", function(e) { + if (control.type == "checkbox") { + localStorage[control.name] = JSON.stringify(control.checked); + } else if (control.type == "range") { + localStorage[control.name] = JSON.stringify(control.value); + } }, false); } refreshSettings(); var settingsItems = settingsMenu.getElementsByTagName("input"); for (var i = 0; i < settingsItems.length; i++) { - setupCheckbox(settingsItems[i]); + setupControl(settingsItems[i]); } if (settingsMenu.addEventListener) {