הפיכת המחשב למקלט שמע (Bluetooth A2DP Sink) באמצעות קוד
ניתן להפוך את המחשב ל"רמקול בלוטוס" על ידי שימוש בשימוש ב-WinRT APIs (בווינדוס) או BlueZ (בלינוקס), המאפשרים למחשב להירשם כצומת A2DP Sink המקבל זרם שמע ממכשירים חיצוניים.
דוגמת קוד בסיסית (Python - WinRT)
כדי להפעיל את היכולת הזו תכנותית, נדרשת גישה לפרופילים של התקני הבלוטוס המזוהים:
קוד לדוגמא:
from winsdk.windows.devices.bluetooth import BluetoothDevice
from winsdk.windows.devices.enumeration import DeviceInformation
async def connect_audio_sink(device_name):
# חיפוש התקנים מותאמים (Paired)
devices = await DeviceInformation.find_all_async(BluetoothDevice.get_device_selector())
for info in devices:
if device_name in info.name:
device = await BluetoothDevice.from_id_async(info.id)
# כאן מתבצע הרישום לשירות ה-A2DP Sink
print(f"Connecting to {info.name} as Audio Source...")
# המערכת תנתב אוטומטית את השמע ל-Output ברירת המחדל
return True
return False
# הרצת החיבור
# asyncio.run(connect_audio_sink("Your_Phone_Name"))
