LG smartTV 设备信息查询方法可依据 LG 开发者网站,大体可分为两种方式:
1. API > Luna Service API
1.1 API > Luna Service API > TV Device Information
获取电视型号modelName,固件版本firmwareVersion,超高清UHD,开发工具版本sdkVersion
webOS.service.request("luna://com.webos.service.tv.systemproperty", {
method: "getSystemInfo",
parameters: {
"keys": ["modelName", "firmwareVersion", "UHD", "sdkVersion"]
"keys": ["modelName", "sdkVersion"]
},
onComplete: function (inResponse) {
var isSucceeded = inResponse.returnValue;
if (isSucceeded) {
console.log("webOS TV Device Information: " + JSON.stringify(inResponse));
var tvModel = inResponse.modelName; //smartTV 电视型号
console.log("tvModel: " + tvModel);
var firmwareVersion = inResponse.firmwareVersion; //固件版本 = 操作系统版本,即webOS操作系统版本
console.log("firmwareVersion : " + firmwareVersion );
var UHD = inResponse.UHD; //是否支持超高清分辨率,"true": 支持;"false": 不支持
console.log("UHD : " + UHD );
var sdkVersion = inResponse.sdkVersion; //webOS TV SDK version,即开发工具webOS TV IDE版本
console.log("sdkVersion : " + sdkVersion );
} else {
console.log("Failed to get TV device information");
return;
}
}
});
1.2 API > Luna Service API > Device Unique ID
获取设备唯一ID UID
webOS.service.request("luna://com.webos.service.sm", {
method: "deviceid/getIDs",
parameters: {
"idType": ["LGUDID"]
},
onSuccess: function (inResponse) {
console.log("webOS TV DeviceID: " + JSON.stringify(inResponse));
var tvUID = inResponse.idList[0].idValue; //设备唯一ID
console.log("tvUID: " + tvUID);
},
onFailure: function (inError) {
console.log("Failed to get tvUID information");
console.log("[" + inError.errorCode + "]: " + inError.errorText);
return;
}
});
2. API > webOSTV.js > webOS
获取电视型号modelName,系统版本osVersion,超高清uhd,开发工具版本sdkVersion
function recordLog(logDetail,logLevel,errorCode,sendImmediately,keepOldCash){
console.log(logDetail);
}
recordLog("The manufacturer is LG",99);
webOS.deviceInfo(function (device) {
var tvModel = device.modelName; //smartTV 电视型号
recordLog("The tvModel is " + tvModel,99);
var osVersion = device.version; //webOS操作系统版本
recordLog("The osVersion is " + osVersion,99);
var sdkVersion = device.sdkVersion; //webOS TV SDK version,即开发工具webOS TV IDE版本
recordLog("The sdkVersion is " + sdkVersion,99);
var uhd = device.uhd; //是否支持超高清分辨率,"true": 支持;"false": 不支持
recordLog("The uhd is " + uhd,99);
});