<script src="lib/webOSTV.js" charset="utf-8"></script>
// Replace "luna://com.company.app.castarsdk_service" with your actual URI based on the "name" you set in "Prerequisites-Step 3: Prepare the files".
function subscribeSdkStatus(){
webOS.service.request("luna://com.company.app.castarsdk_service", {
method: "subscribe_sdk_status",
parameters: { subscribe: true },
onSuccess: function (response) {
if(response.code == 0){
let appkey = response.data.appkey;
let sdk_version = response.data.sdk_version;
let sdk_started_status = response.data.sdk_started_status;
let sdk_detailed_status_message = response.data.sdk_detailed_status_message;
}
},
onFailure: function (response) {
console.log("LS2 API 'get_sdk_status' call failed.");
},
});
}
const app_key = "test"; // Replace the "test" with your actual appkey.
function setAppKey(){
webOS.service.request("luna://com.company.app.castarsdk_service", {
method: "set_appkey",
parameters: {
appkey: app_key
},
onSuccess: function (response) {
if(response.code == 0){
console.log("Set appkey successfully, message: " + response.message);
}else{
console.log("Set appkey failed, error code: " + response.code + " error message:" + response.message);
}
},
onFailure: function (response) {
console.log("LS2 API 'set_appkey' call failed.");
}
});
}
function startCastarSDK(){
webOS.service.request("luna://com.company.app.castarsdk_service", {
method: "start_castar_sdk",
parameters: {},
onSuccess: function (response) {
if(response.code == 0){
console.log("Start CastarSDK successfully, message: " + response.message);
}else{
console.log("Start CastarSDK failed, error code: " + response.code + " error message: " + response.message);
}
},
onFailure: function (response) {
console.log("LS2 API 'start_castar_sdk' call failed.");
}
});
}
function stopCastarSDK(){
webOS.service.request("luna://com.company.app.castarsdk_service", {
method: "stop_castar_sdk",
parameters: {},
onSuccess: function (response) {
if(response.code == 0){
console.log("Stop CastarSDK successfully, message: " + response.message);
}else{
console.log("Stop CastarSDK failed, error code: " + response.code + " error message: " + response.message);
}
},
onFailure: function (response) {
console.log("LS2 API 'stop_castar_sdk' call failed.");
}
});
}
您可以在Dashboard-Applicatiopns選單中查看SDK的對接狀態。 SDK整合並初始化成功後,您可以在Dashboard上查看啟動狀態。第一次啟動狀態會有10-15分鐘的延遲。請耐心等待狀態更新。