From 84222434655029bcadfe978852a7ce35add6eefd Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Tue, 22 Jan 2019 17:49:18 -0600 Subject: [PATCH] Volume should be saved across restarts --- src/app-configuration.defaults | 11 ++++++++--- src/controller/mainController.py | 4 ++++ src/presenters/player.py | 2 +- src/session.defaults | 7 ------- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/app-configuration.defaults b/src/app-configuration.defaults index 9514ead..cbdc967 100644 --- a/src/app-configuration.defaults +++ b/src/app-configuration.defaults @@ -1,6 +1,11 @@ [app-settings] -username = string(default="") -password = string(default="") language = string(default="system") use_proxy = boolean(default=False) -first_start = boolean(default=True) \ No newline at end of file +first_start = boolean(default=True) + +[sound] +volume = integer(default=100) +input_device = string(default="Default") +output_device = string(default="Default") +session_mute = boolean(default=False) +current_soundpack = string(default="default") \ No newline at end of file diff --git a/src/controller/mainController.py b/src/controller/mainController.py index dcb3dd8..5a291ce 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -9,6 +9,7 @@ import output import presenters import interactors import views +import config from vk_api.exceptions import LoginRequired, VkApiError from requests.exceptions import ConnectionError from pubsub import pub @@ -235,6 +236,9 @@ class Controller(object): log.debug("Receibed an exit signal. closing...") self.set_offline() self.disconnect_events() + volume = player.player.volume + config.app["sound"]["volume"] = volume + config.app.write() self.window.Destroy() wx.GetApp().ExitMainLoop() diff --git a/src/presenters/player.py b/src/presenters/player.py index 899b4f3..6a170f9 100644 --- a/src/presenters/player.py +++ b/src/presenters/player.py @@ -24,7 +24,7 @@ class audioPlayer(object): def __init__(self): self.is_playing = False self.stream = None - self.vol = 100 + self.vol = config.app["sound"]["volume"] self.is_working = False self.queue = [] self.playing_track = 0 diff --git a/src/session.defaults b/src/session.defaults index 59acf50..a0fa2a4 100644 --- a/src/session.defaults +++ b/src/session.defaults @@ -17,13 +17,6 @@ count_for_wall_buffers = integer(default=100) count_for_video_buffers = integer(default=200) count_for_audio_buffers = integer(default=1000) -[sound] -volume = float(default=1.0) -input_device = string(default="Default") -output_device = string(default="Default") -session_mute = boolean(default=False) -current_soundpack = string(default="default") - [chat] notify_online = boolean(default=True) notify_offline = boolean(default=True)