Skip to content

Commit

Permalink
✨ setting for decibel volume
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerogar committed Sep 11, 2020
1 parent c13dbcc commit 764a2d6
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 16 deletions.
1 change: 1 addition & 0 deletions STORE_VARIABLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
| `settings-custom-css-page` | Boolean | `true` or `false` | `false` | Custom css for web page |
| `settings-volume` | String | `0` ~ `100` | `100` | Playback volume |
| `settings-volume-media-keys` | Boolean | `true` or `false` | `false` | Enable media volume keys for the playback volume |
| `settings-decibel-volume` | Boolean | `true` or `false` | `true` | Replace the volume control with a decibel based system |

## Window
| Key | Type | Values | Default | Description |
Expand Down
3 changes: 2 additions & 1 deletion src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
"LABEL_SETTINGS_TAB_SHORTCUTS_GLOBAL": "Global",
"LABEL_SETTINGS_TAB_SHORTCUTS_LOCAL": "Lokal",
"LABEL_SETTINGS_TAB_SHORTCUTS_PRESS_ANY_KEYS": "Drücke eine beliebige Taste",
"LABEL_SETTINGS_TAB_SHORTCUTS_VOLUME_MEDIA_KEYS": "Lautstärke Medientasten aktivieren",
"LABEL_SETTINGS_TAB_SHORTCUTS_VOLUME_MEDIA_KEYS": "Lautstärke Medientasten steuern nur App Lautstärke",
"LABEL_SETTINGS_TAB_PLAYBACK_DECIBEL_VOLUME": "Lautstärkeregelung von '%' zu 'dB' ändern",
"MEDIA_CONTROL_MUTE_UNMUTE": "Ton aus / Ton an",
"MEDIA_CONTROL_NEXT": "Weiter",
"MEDIA_CONTROL_PAUSE": "Anhalten",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
"LABEL_SETTINGS_TAB_SHORTCUTS_LOCAL": "Local",
"LABEL_SETTINGS_TAB_SHORTCUTS_PRESS_ANY_KEYS": "Press any key",
"LABEL_SETTINGS_TAB_SHORTCUTS": "Shortcuts",
"LABEL_SETTINGS_TAB_SHORTCUTS_VOLUME_MEDIA_KEYS": "Enable media volume keys",
"LABEL_SETTINGS_TAB_SHORTCUTS_VOLUME_MEDIA_KEYS": "Volume media keys only control app volume",
"LABEL_SETTINGS_TAB_PLAYBACK_DECIBEL_VOLUME": "Switch volume control from '%' to 'dB'",
"LABEL_SETTINGS": "Settings",
"LYRICS": "Lyrics",
"MEDIA_CONTROL_MINIPLAYER": "Open/Close Miniplayer",
Expand Down
18 changes: 18 additions & 0 deletions src/pages/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,24 @@
</p>
</td>
</tr>
<tr>
<td>
<span
i18n="i18n_LABEL_SETTINGS_TAB_PLAYBACK_DECIBEL_VOLUME"
></span>
</td>
<td class="right">
<div class="switch">
<label>
<input
type="checkbox"
id="settings-decibel-volume"
/>
<span class="lever"></span>
</label>
</div>
</td>
</tr>
</tbody>
</table>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/pages/settings/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ document.addEventListener('DOMContentLoaded', function () {
newValue: enableVolumeMediaKeys ? 'VolumeDown' : 'disabled',
})
})
initElement('settings-decibel-volume', 'click')
initElement(
'settings-disable-hardware-acceleration',
'click',
Expand Down
29 changes: 19 additions & 10 deletions src/providers/mediaProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const __ = require('./translateProvider')
const systemInfo = require('../utils/systemInfo')
const infoPlayerProvider = require('../providers/infoPlayerProvider')
const path = require('path')
const settingsProvider = require('./settingsProvider')

function mediaPlayPauseTrack(mainWindow) {
mainWindow.webContents.sendInputEvent({ type: 'keydown', keyCode: ';' })
Expand All @@ -28,19 +29,27 @@ function mediaDownVote(mainWindow) {
}

function mediaVolumeUp(mainWindow) {
let percent = infoPlayerProvider.getPlayerInfo().volumePercent
infoPlayerProvider.setVolume(
mainWindow.webContents,
decibelToPercent(percentToDecibel(percent) + 1.5)
)
if (settingsProvider.get('settings-decibel-volume')) {
let percent = infoPlayerProvider.getPlayerInfo().volumePercent
infoPlayerProvider.setVolume(
mainWindow.webContents,
decibelToPercent(percentToDecibel(percent) + 1.5)
)
} else {
mainWindow.webContents.sendInputEvent({ type: 'keydown', keyCode: '=' })
}
}

function mediaVolumeDown(mainWindow) {
let percent = infoPlayerProvider.getPlayerInfo().volumePercent
infoPlayerProvider.setVolume(
mainWindow.webContents,
decibelToPercent(percentToDecibel(percent) - 1.5)
)
if (settingsProvider.get('settings-decibel-volume')) {
let percent = infoPlayerProvider.getPlayerInfo().volumePercent
infoPlayerProvider.setVolume(
mainWindow.webContents,
decibelToPercent(percentToDecibel(percent) - 1.5)
)
} else {
mainWindow.webContents.sendInputEvent({ type: 'keydown', keyCode: '-' })
}
}

function mediaForwardTenSeconds(mainWindow) {
Expand Down
7 changes: 3 additions & 4 deletions src/utils/defaultSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ settingsProvider.setInitialValue('settings-tray-icon', true)

settingsProvider.setInitialValue('settings-volume', 100)

settingsProvider.setInitialValue(
'settings-enable-double-tapping-show-hide',
false
)
settingsProvider.setInitialValue('settings-volume-media-keys', false)

settingsProvider.setInitialValue('settings-decibel-volume', true)

0 comments on commit 764a2d6

Please sign in to comment.