Replace original vmichalak sonos-controller with custom fork

The custom fork is able to control also the volume
of announcement, which is desired feature.
This commit is contained in:
2020-05-16 12:41:34 +02:00
parent 749be67b72
commit 4c549dd0d5
2 changed files with 4 additions and 21 deletions

View File

@@ -1,12 +1,10 @@
package io.bartek.ttsserver.core.sonos.worker
import com.vmichalak.sonoscontroller.SonosDevice
import com.vmichalak.sonoscontroller.SonosDiscovery
import com.vmichalak.sonoscontroller.model.PlayState
import io.bartek.ttsserver.service.foreground.ForegroundService
import io.bartek.ttsserver.service.state.ServiceState
import io.bartek.ttsserver.core.tts.engine.TTSEngine
import io.bartek.ttsserver.core.web.dto.SonosDTO
import io.bartek.ttsserver.service.foreground.ForegroundService
import io.bartek.ttsserver.service.state.ServiceState
import java.util.concurrent.BlockingQueue
class SonosWorker(
@@ -29,21 +27,6 @@ class SonosWorker(
val file = tts.createTTSFile(data.text, data.language)
val filename = file.name
val url = "http://$host:$port/sonos/$filename"
it.announce(url, data.volume)
it.clip(url, data.volume, "")
}
private fun SonosDevice.announce(url: String, volume: Int) {
val currentPlayState = this.playState
val currentVolume = this.volume
this.stop()
this.volume = volume
this.clip(url, "")
this.volume = currentVolume
when(currentPlayState) {
PlayState.PLAYING -> this.play()
else -> this.stop()
}
}
}