screenMirror method
Future<SendPort>
screenMirror({
- required ReceivePort answer,
- ScreenRecordOptions recordingOptions = const ScreenRecordOptions(),
- FFPlayOptions playOptions = const FFPlayOptions(),
- String ffplayPath = 'ffplay',
Start screen recording
answer - ReceivePort to listen for the response
recordingOptions - ScreenRecordOptions
playOptions - FFPlayOptions
Returns SendPort to control the screen recording
Example:
final answer = ReceivePort();
final sendPort = await client.shell().screenMirror(answer: answer);
sendPort.send('start');
Future.delayed(Duration(seconds: 10), () {
sendPort.send('stop');
});
await for (final message in answer) {
print(message);
}
Implementation
Future<SendPort> screenMirror({
required ReceivePort answer,
ScreenRecordOptions recordingOptions = const ScreenRecordOptions(),
FFPlayOptions playOptions = const FFPlayOptions(),
String ffplayPath = 'ffplay',
}) async {
final response = ReceivePort();
final adbPath = _bridge.executor.adbPath;
final screenArgs = [
..._connection.arguments,
'shell',
'screenrecord',
...recordingOptions.toArgs(),
'-',
];
final ffplayArgs = [...playOptions.toArgs()];
await Isolate.spawn(_screenMirrorTask, response.sendPort);
final sendPort = await response.first;
sendPort.send([
'setup',
answer.sendPort,
adbPath,
screenArgs,
ffplayPath,
ffplayArgs,
]);
return sendPort;
}