Closed ToddInIowa closed 1 year ago
The only issue I see you can get here is when tempHtml
variable is not declared
A few questions on your usage, as I've rechecked it and the functionality should still be working on latest public XBC and xjs 2.10.2 (as shown in screenshot below)
The issue with this is attempting to use tempHtml
outside of the promise before the promise had been resolved. For a bit more context the usage was
var tempHtml = "some valid HTML"
// ...
xjs.Scene.getBySceneIndex(0).then(function(focusscene) {
focusscene.getName().then(function(name) {
tempHtml += name;
});
});
// ...
tempHtml += "other HTML"
document.getElementById(id).innerHTML = tempHtml;
Fixing the logic and using await
to get the name fixes the problem.
I am using: XSplit Broadcaster v4.4(4.4.2211.0404) xjs version 2.10.2
I have not been able to get the remote debugger to work. So I have used Chrome to debug the portions of my code that don't need xjs, and then fly blind for the xjs stuff. Is there any documentation on how to use the debugger with more detail than "please try using lower versions via CEF builds or the like."
As mentioned above @jvens swapped around my logic and used async calls instead of promises to resolve my issue:
let scene = await xjs.Scene.getBySceneIndex(0);
var tempHtml = "some valid HTML"
// ...
tempHtml += await scene.getName();
tempHtml += "other HTML"
document.getElementById(id).innerHTML = tempHtml;
The promise concept is not one that I am familiar with so I didn't realize I needed to keep everything contained.
Good catch there, @jvens :) Failed to think of that possibility without the full code snippet.
As a reference, the framework has been developed before async-await became a thing and using promises is the go-to functionality for asynchronous methods and this is reflected in the xjs framework support website. I believe that most, if not all, of the snippets in the website still stay true though it can use a fresher update.
For debugging, latest chrome now again has support:
chrome://inspect/#devices
-- click on Configure
and add localhost:9222
in the Target discovery settings popup
-- All discoverable pages should now be displayed (may take a few seconds/minutes)
-- Click inspect
under the extension you are about to debug to launch its remote debugging page
I'm trying to get the name of the scenes that are configured, but the above code can't even get the scene name of sceneIndex 0. What is wrong with this code?