add volume management

This commit is contained in:
grunjol
2016-03-22 19:44:44 -03:00
parent 9518670c7b
commit fc6d8e7b7d
4 changed files with 46 additions and 0 deletions

View File

@@ -236,6 +236,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')
@@ -280,6 +283,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')