def _fadeout_playback(self): duration = self._app_settings.sleep_timer_fadeout_duration * 20 current_vol = player.get_volume() for i in range(0, duration): player.set_volume(max(current_vol - (i / duration), 0)) time.sleep(0.05) log.info("Fadeout completed.") self.play_pause() player.set_volume(current_vol) self.emit_event("fadeout-finished", None) self._fadeout_thread = None
def __stop_playback(self): """ Stops playback after gradually fading out (if enabled). """ if tools.get_glib_settings().get_boolean("sleep-timer-fadeout"): duration = tools.get_glib_settings().get_int("sleep-timer-fadeout-duration") * 20 current_vol = player.get_volume() for i in range(0, duration): player.set_volume(current_vol - (i / duration)) time.sleep(0.05) player.set_volume(current_vol) if player.get_gst_player_state() == Gst.State.PLAYING: player.play_pause(None) Gdk.threads_add_idle(GLib.PRIORITY_DEFAULT_IDLE, self.timer_scale.get_adjustment().set_value, 0.0)
def __stop_playback(self): """ Stops playback after gradually fading out (if enabled). """ if self._app_settings.sleep_timer_fadeout: duration = self._app_settings.sleep_timer_fadeout_duration * 20 current_vol = player.get_volume() for i in range(0, duration): player.set_volume(max(current_vol - (i / duration), 0)) time.sleep(0.05) player.set_volume(current_vol) if player.get_gst_player_state() == Gst.State.PLAYING: Gdk.threads_add_idle(GLib.PRIORITY_HIGH, player.play_pause, None) Gdk.threads_add_idle(GLib.PRIORITY_HIGH, self.timer_scale.get_adjustment().set_value, 0.0) self.__handle_system_power_event()
def __on_volume_changed(self, widget, value): """ Sets the ui value in the player. """ player.set_volume(value) tools.get_glib_settings().set_double("volume", value)
def __on_volume_changed(self, widget, value): """ Sets the ui value in the player. """ player.set_volume(value) self._application_settings.volume = value
def volume(self, new_value: float): player.set_volume(new_value) self._app_settings.volume = new_value