initDeviceInfo method
void
initDeviceInfo()
Implementation
void initDeviceInfo() async {
if (CastDeviceType.ChromeCast == deviceType) {
if (null != attr && null != attr!['fn']) {
_friendlyName = utf8.decode(attr!['fn']!);
if (null != attr!['md']) {
_modelName = utf8.decode(attr!['md']!);
}
} else {
// Attributes are not guaranteed to be set, if not set fetch them via the eureka_info url
// Possible parameters: version,audio,name,build_info,detail,device_info,net,wifi,setup,settings,opt_in,opencast,multizone,proxy,night_mode_params,user_eq,room_equalizer
try {
bool trustSelfSigned = true;
HttpClient httpClient = HttpClient()
..badCertificateCallback =
((X509Certificate cert, String host, int port) =>
trustSelfSigned);
IOClient ioClient = new IOClient(httpClient);
final uri = Uri.parse(
'https://$host:8443/setup/eureka_info?params=name,device_info');
http.Response response = await ioClient.get(uri);
Map deviceInfo = jsonDecode(response.body);
if (deviceInfo['name'] != null && deviceInfo['name'] != 'Unknown') {
_friendlyName = deviceInfo['name'];
} else if (deviceInfo['ssid'] != null) {
_friendlyName = deviceInfo['ssid'];
}
if (deviceInfo['model_name'] != null) {
_modelName = deviceInfo['model_name'];
}
} catch (exception) {
print(exception.toString());
}
}
}
}