Closed Joshimuz closed 7 years ago
You are correct in saying that the Text Source is a full HTML source, and this allows it to support extensive customizations such as our custom scripts. setValue
and getValue
are really useful primarily for "native" sources like Images or Files for example, but they are mostly there as a fallback for operations which are not abstracted in xjs.
It appears that we are now entering a discussion of letting HTML plugins expose some specific API for extensions to use. While this is not supported now (and neither does the Text Source actually have a public API), for now we might be able to provide you with some undocumented internal calls that might be helpful.
Assigning to @SML-MeSo to investigate a potential solution; right now maybe we just need something that doesn't require changes to the Text plugin or to the plugin framework. We can study how to integrate this into a general "HTML plugin API" flow later on.
Hii! Sorry about the late reply. Normally, all you need are the HTMLSource's loadConfig, applyConfig and/or requestSaveConfig methods, but this is if the HTML source itself uses the xjs-framework. However, the text source is written way before the framework and as such, doesn't rely on it for configuration. Despite of this, here's what you can do:
textItem.loadConfig().then( config => {
textConfig = config;
textConfig['text'] = 'Whatever text';
return textItem.call('SetConfiguration', JSON.stringify(textConfig));
})
Note: Text source should not be using custom script since custom script overwrites the text property. Also this can only be used via the HTMLItem class, and not the HTMLSource, which is definitely a bug since it should be a source property, already filed as #155
Awesome, thanks a lot @SML-MeSo your explanation and code block works perfectly.
Is it really not supported by the API to edit a Text Source easily? The API reference website doesn't even list Text as a source type, and when I tried getting the value via ".getValue()" and ".setValue()" I just get the HTML, so I guess "Text" in XSplit is really just a HTML source. However I assumed that the API would provide an easy way to edit a regular text source, as being able to exit the text on the screen seems like pretty basic functionally to me. Is there a way of editing the text value of the HTML? Other than doing some string wizardry I can't think of an easy method.