好,你把整个函数替换一下,播放一次重连一次看看
async def airplay(event_loop):
atvs = await pyatv.scan(LOOP, hosts=[IP])
if len(atvs) == 0:
print("No device found")
else:
atv = atvs[0]
#atv_interface = await pyatv.connect(atv, event_loop)
#listener = MyPushListener()
#atv_interface.push_updater.listener = listener
#atv_interface.push_updater.start()
try:
atv_interface = await pyatv.connect(atv, event_loop)
await atv_interface.stream.stream_file(MUSIC)
atv_interface.close()
atv_interface = await pyatv.connect(atv, event_loop)
await atv_interface.stream.stream_file(MUSIC)
atv_interface.close()
except Exception as e:
print(e)
#atv_interface.close()
|