That's how I did it initially. I then changed it to be like so:
mediaItem.loadAssetID = getFPSAssetId;
mediaItem.loadCertficate = getCertificate;
mediaItem.loadKey = getFPSKey;
where getFPSAssetId, getCertificate, getFPSKey are defined at the top of the JS page like so:
function getFPSAssetId(uri, callback) {
console.log("===== HERE === ");
var assetID = fpsMgr.assetIDFromURI(uri);
if (assetID != null) {
console.log("======= [FPS] =============== [FPS]: Successfully parsed asset ID: " + assetID);
callback(assetID);
} else {
console.log("=============== [FPS]: Error parsing asset ID from URI: " + uri);
callback(null, "Error parsing asset ID from URI: " + uri);
}
};
function getCertificate(uri, callback) {
console.log("==== Getting the certificate");
var certUrl = fpsMgr.getFPSCertURL();
SkyChnlApi.debugLog("======= [FPS] certUrl: " + certUrl);
http.apiRequest(certUrl, "GET", true, "", function(certRequest) {
if (certRequest.status == 200) {
console.log("Received cert data: " + certRequest.responseDataAsBase64);
callback(certRequest.responseDataAsBase64);
} else {
console.log("Error receiving cert data" + certRequest.status);
callback(null, "Got bad response from server: " + certRequest.status);
}
});
};
function getFPSKey(uri, requestData, callback) {
console.log("======= [FPS] getting the FPS asset key");
var assetID = fpsMgr.assetIDFromURI(uri);
var postBody = "payload=" + requestData + "&id=" + assetID;
// if (fpsToken) postBody += "&fpstoken=" + fpsToken;
// fpsToken = null; //reset right away.
var keyUrl = fpsMgr.getFPSCKCURL();
console.log("======= [FPS] keyurl: " + keyUrl + " sending " + postBody);
httpMgr.apiRequest(keyUrl, "POST", true, postBody, function(keyRequest) {
if (keyRequest.status == 200) {
// The example server implementation wraps the key response blob in
// <ckc>...</ckc> tags. Partners can encode the key response in any
// manner they wish.
console.log("======== " + keyRequest);
var response = keyRequest.responseText;
console.log("=============== [FPS]: " + response);
callback(response, null, null);
} else {
console.log("=============== [FPS]: Got bad response from server: " + keyRequest.status);
callback(null, null, "Got bad response from server: " + keyRequest.status);
}
});
// callback(keyValue, renewDate, error);
};
fpsMgr and httpMgr represent objects that are supposed to return relevant information. My whole confusion is that even as defined I don't see any log statements. I would expect that even if I didn't base64 encode the information I would at least see the console statements at the beginning of each function right?