Closed Alex-Beng closed 2 years ago
Does the program throw any other exception?
By the way, what's your phone's android version?
I think the problem is that you started the server twice.
Can you try:
from adbutils import adb
import scrcpy
def on_frame(frame):
if frame is not None:
print(type(frame))
device = adb.device()
client = scrcpy.Client(
max_width=540, device=device)
client.add_listener(scrcpy.EVENT_FRAME, on_frame)
client.start()
And if you want to start the client in an independent thread, you can use client.start(threaded=True)
, and the main loop won't be blocked.
I think the problem is that you started the server twice. Can you try:
from adbutils import adb import scrcpy def on_frame(frame): if frame is not None: print(type(frame)) device = adb.device() client = scrcpy.Client( max_width=540, device=device) client.add_listener(scrcpy.EVENT_FRAME, on_frame) client.start()
And if you want to start the client in an independent thread, you can use
client.start(threaded=True)
, and the main loop won't be blocked.
It works for me! By the way, the loop refers to scrcpy_ui/main.py in L169-L171. In the forward mode, it only send once Dummy byte. So it seems that the QT demo won't work? Due to some environmental problems, I can not install Pyside6 or PyQt6. :-)
https://github.com/leng-yue/py-scrcpy-client/blob/a8222520c09f968ad0449eba280a96e8bd95e29c/scrcpy_ui/main.py#L61-L64 https://github.com/leng-yue/py-scrcpy-client/blob/a8222520c09f968ad0449eba280a96e8bd95e29c/scrcpy_ui/main.py#L169-L171
No, this works as expected. It is used to detect whether the QT window is closed. While QT is not closed, the program should reconnect after users change the device.
If you have more questions, please reopen the issue.
I'm trying to write a simplest demo like
for the hardware setting, i only have a phone with USB cable connected. all run in Ubuntu 16.04, python 3.9.5,
here is the conda list