-
-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@yume-chan/scrcpy documentation for standalone package #455
Comments
The README is up to date, in fact it's too up to date that it applies to the unreleased code.
My plan for new release is to wait after next Scrcpy release, which includes my PR Genymobile/scrcpy#3369 to improve scrolling. Without that scrolling is barely working on Web. But if you want, I can do another release now. |
Got it! No, thank you. I'll wait. |
I tried to install it locally, currently the |
In exported types from If you don't use those types (with names start with |
For a general usage guide, as you have your own backend, you need to supply the two socket streams from Scrcpy server to this package. This package uses Web Streams API (https://developer.mozilla.org/en-US/docs/Web/API/Streams_API), it's similar to Node.js streams, but not same. The video socket can only be read, so you need to create a ya-webadb/libraries/adb-backend-ws/src/index.ts Lines 15 to 58 in c1128a3
All chunks in those streams should be Then you need to create an option value ( To parse the video stream, pipe the video stream to the video stream deserializer videoSocket
.pipeThrough(options.createVideoStreamTransformer())
.pipeTo(new WritableStream({
write(packet) {
switch (packet.type) {
case 'configuration':
console.log(packet.data.croppedWidth, packet.data.croppedHeight);
break;
case 'frame':
console.log(packet.keyframe, packet.pts, packet.data);
break;
}
}
})); To send control messages to device, create a const controller = new ScrcpyControlMessageSerializer(controlSocket, options); Then hook up your UI to call methods on the serializer: await controller.backOrScreenOn(AndroidKeyEventAction.Down);
await controller.backOrScreenOn(AndroidKeyEventAction.Up);
await controller.injectTouch({
screenWidth: 1920,
screenHeight: 1080,
action: AndroidMotionEventAction.Down,
buttons: 0,
pointerId: 0n,
pointerX: 500,
pointerY: 500,
pressure: 0,
}) Exact parameters of each method are not documented too much, check my demo for examples. |
I have released version 0.0.17 so you can use them directly. |
You are truly generous. Thanks for the super-detailed answer |
Hi, I'd like to use only the
yume-chan/scrcpy
package to integrate Scrcpy in a React frontend that integrates with a Node.js backend. I was reading the specific README at this link but I found that something is missing, like:ScrcpyVideoStreamPacket
ScrcpyControlMessageSerializer
Probably that page is not updated but I would very much like a guide to integrate your frontend package with a different backend implementation.
The text was updated successfully, but these errors were encountered: