scanChromecastDevices function
Future<List<DiscoveredDevice> >
scanChromecastDevices({})
Scan for Chromecast devices in the local network
onDeviceFound 回調函數,當找到新裝置時調用
Implementation
Future<List<DiscoveredDevice>> scanChromecastDevices({
Function(DiscoveredDevice)? onDeviceFound,
Duration scanDuration = const Duration(seconds: 5), // 改名為 scanDuration
MDnsClient? sharedClient,
bool stopClientOnFinish = true,
}) async {
return scanMdnsDevices(
serviceType: '_googlecast._tcp',
mdnsType: '_googlecast._tcp',
deviceFactory: ({
required String ip,
required int port,
required String serviceName,
required Map<String, String> txtMap,
List<String>? mdnsTypes,
}) {
return DiscoveredDevice.fromChromecast(
ip: ip,
port: port,
serviceName: serviceName,
txtMap: txtMap,
);
},
onDeviceFound: onDeviceFound,
logTag: 'mDNS',
scanDuration: scanDuration, // 傳遞 scanDuration
sharedClient: sharedClient,
stopClientOnFinish: stopClientOnFinish,
);
}