Merge pull request #202 from grunjol/feature-volume-management-clean

Add volume management
This commit is contained in:
Feross Aboukhadijeh
2016-03-25 23:46:59 -07:00
4 changed files with 46 additions and 0 deletions

View File

@@ -239,6 +239,9 @@ function dispatch (action, ...args) {
if (action === 'playbackJump') {
jumpToTime(args[0] /* seconds */)
}
if (action === 'changeVolume') {
changeVolume(args[0] /* increase */)
}
if (action === 'mediaPlaying') {
state.playing.isPaused = false
ipcRenderer.send('blockPowerSave')
@@ -283,6 +286,22 @@ function jumpToTime (time) {
}
}
function changeVolume (delta) {
// change volume with delta value
setVolume(state.playing.volume + delta)
}
function setVolume (volume) {
// check if its in [0.0 - 1.0] range
volume = Math.max(0, Math.min(1, volume))
if (Cast.isCasting()) {
Cast.setVolume(volume)
} else {
state.playing.setVolume = volume
update()
}
}
function setupIpc () {
ipcRenderer.send('ipcReady')