SplitmediaLabsLimited / xjs

XSplit JS Framework. Make plugins for XSplit Broadcaster, quickly and easily.
Other
39 stars 11 forks source link

Allow `addToScene` calls to return UIDs of newly added sources #232

Closed mikeybanez closed 5 years ago

mikeybanez commented 6 years ago

We would want to reliably know the ID of a source that has been programmatically added to a scene through xjs, without doing all kinds of hacky workarounds. Currently, our addToScene promises always resolve with a boolean (potentially always true?), but we can extend this by returning a string ID instead.

For implementation, we can test out using the events listed in CPPCORE-1551. Please note that there are performance considerations here, because this currently requires to subscribe to events using AppSubscribeEvents. We may need to make this behavior opt-in.

mikeybanez commented 6 years ago

Note that this is very similar to the first point in #122 (but let's keep that issue open because 3.0.0 might look very differently).

But it might be a worthwhile idea to return Source items immediately instead of the raw ID. Something to discuss with @SML-MeSo just before we start to implement. (There may be cases related to pasting or with linked items which need to be studied first)

nelson-temporal commented 5 years ago

Done. To enable returning of item id of added items ready must have config value { listenToItemAdd: true }. e.g.

xjs.ready({
    listenToItemAdd: true
}).then(() => {
    //your codes here
});

Still there is yet no way to get error response for this action.