update
This commit is contained in:
parent
3f4c49ccf2
commit
cf3e53f8ba
@ -71,18 +71,18 @@ class MediaSourceController(ABC):
|
|||||||
|
|
||||||
class BluetoothController(MediaSourceController):
|
class BluetoothController(MediaSourceController):
|
||||||
"""Контроллер для Bluetooth аудио."""
|
"""Контроллер для Bluetooth аудио."""
|
||||||
|
|
||||||
def __init__(self, bt_service: Any):
|
def __init__(self, bt_service: Any):
|
||||||
self._bt_service = bt_service
|
self._bt_service = bt_service
|
||||||
self._music_mac: str | None = None
|
self._music_mac: str | None = None
|
||||||
|
|
||||||
def set_music_mac(self, mac: str | None) -> None:
|
def set_music_mac(self, mac: str | None) -> None:
|
||||||
"""Установить приоритетный MAC для музыки."""
|
"""Установить приоритетный MAC для музыки."""
|
||||||
self._music_mac = mac
|
self._music_mac = mac
|
||||||
# Синхронизируем с сервисом
|
# Синхронизируем с сервисом
|
||||||
if self._bt_service:
|
if self._bt_service:
|
||||||
self._bt_service.set_music_mac(mac)
|
self._bt_service.set_music_mac(mac)
|
||||||
|
|
||||||
def get_music_mac(self) -> str | None:
|
def get_music_mac(self) -> str | None:
|
||||||
"""Получить приоритетный MAC для музыки."""
|
"""Получить приоритетный MAC для музыки."""
|
||||||
return self._music_mac
|
return self._music_mac
|
||||||
@ -199,7 +199,7 @@ class MediaController(QObject):
|
|||||||
self._settings = QSettings("car_ui", "ui")
|
self._settings = QSettings("car_ui", "ui")
|
||||||
self._controllers: dict[str, MediaSourceController] = {}
|
self._controllers: dict[str, MediaSourceController] = {}
|
||||||
self._current_mode: str = "bluetooth"
|
self._current_mode: str = "bluetooth"
|
||||||
|
|
||||||
# Регистрируем контроллеры
|
# Регистрируем контроллеры
|
||||||
self._register_controllers()
|
self._register_controllers()
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ class MediaController(QObject):
|
|||||||
# Если переключаемся с Bluetooth на CarPlay - ставим паузу
|
# Если переключаемся с Bluetooth на CarPlay - ставим паузу
|
||||||
if self._current_mode == "bluetooth" and mode == "carplay":
|
if self._current_mode == "bluetooth" and mode == "carplay":
|
||||||
self._controllers["bluetooth"].pause()
|
self._controllers["bluetooth"].pause()
|
||||||
|
|
||||||
# Если переключаемся на Bluetooth - подключаем приоритетное устройство
|
# Если переключаемся на Bluetooth - подключаем приоритетное устройство
|
||||||
elif mode == "bluetooth":
|
elif mode == "bluetooth":
|
||||||
bt_controller = self._controllers["bluetooth"]
|
bt_controller = self._controllers["bluetooth"]
|
||||||
@ -229,7 +229,8 @@ class MediaController(QObject):
|
|||||||
if music_mac:
|
if music_mac:
|
||||||
# Пытаемся подключить приоритетное устройство
|
# Пытаемся подключить приоритетное устройство
|
||||||
bt_controller.connect_device(music_mac)
|
bt_controller.connect_device(music_mac)
|
||||||
|
self._controllers["bluetooth"].play()
|
||||||
|
|
||||||
self._current_mode = mode
|
self._current_mode = mode
|
||||||
# Сигнал о смене режима для обновления UI
|
# Сигнал о смене режима для обновления UI
|
||||||
self.metadata_changed.emit(self.get_metadata())
|
self.metadata_changed.emit(self.get_metadata())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user