0

我想将装有 Ubuntu 18.04 的笔记本电脑上的音乐流式传输到音频设备 (LG CM2760)。我用 Python 编写了简短的脚本,我想在其中连接我的音频设备然后播放音乐。我不确定,但认为连接建立正确,因为 LG 显示了我的笔记本电脑的名称。不幸的是,当我开始“流式传输”时,只有沉默。问题可能与歌曲的字节版本有关,但我已经进行了 2 天的研究,但没有发现任何可以帮助我解决这个问题的方法。

我试图将歌曲转换为其他格式。

import bluetooth
from time import sleep

uuid_to_find = "110D"
service_matches = bluetooth.find_service(uuid=uuid_to_find)

first_match = service_matches[0]
port = first_match["port"]
host = first_match["host"]

print(port)
print(host)

sock = bluetooth.BluetoothSocket(bluetooth.L2CAP)
sock.connect((host, port))

song = open("/home/adrian_chlebosz/Downloads/song.wav", 'rb')
byte_array_song = bytearray(song.read())
song.close()

max_mtu_song = list()
for i in range(0, 64000):
    max_mtu_song.append(bytes(byte_array_song[(671 * i):(671 * (i +
                                                                1))]))

for i in range(0, len(max_mtu_song)):
    sock.send(max_mtu_song[i])
    sleep(0.5)
4

0 回答 0