Comments (7)
I assigned this to [email protected] for now, so let's revisit and discuss with the core team general improvements to how extensions are handled. And then we can see a clearer schedule for implementing these changes in XSplit.
from xjs.
One specific usecase I would see for this, is to list and activate macros (which are handled through an extension AFAICS) from an xjs extension.
from xjs.
Any progress on this?
I see there is an iSourceHtml.call()
method that allows calling functions within a source plugin. The docs say "call a pre-exposed function", but I can't find any documentation on how to expose functions. A quick experiment shows that any global javascript functions can be called this way, maybe an example or some additional documentation would be useful?
And is there a way to communicate back from a source plugin (e.g. by raising events)? I can imagine one could abuse the item-changed
event that can be caught using Item.on
for this, but just changing some unused property (and then using the property value or a subsequent iSourceHtml.call()
to figure out the actual event that happened), but it would be nicer if a source plugin could just raise arbitrary events too.
Also, it seems that this interaction only works on source plugins, you cannot call code in an extension plugin, since it has no corresponding item or other object.
from xjs.
Sorry for the late reply.
But yes you are right, the function should be a global function to be called.
Right now there is no direct way for source to extension communication due to limitations.
Right now Macros listen to events from sources by listening to storage
(https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event) events.
This can be seen on Macros' triggers to slide shows.
There is another which is the Broadcast Channel API
(https://developer.mozilla.org/en-US/docs/Web/API/Broadcast_Channel_API) which is where Macros would be headed to.
As you can see both are limited to same origin.
Hopefully this has been helpful to you for now.
I guess the limitations are there for security.
Until then, we are not able to include any generic communication between source to extension to xjs.
from xjs.
@nelson-temporal Thanks for the suggestions. The same-origin limitation is not a problem for us (all our extensions are local files), so these APIs are indeed ideal to communicate between different source/extension plugins. We tried them, and they work as expected.
For anyone else reading this, the APIs @nelson-temporal links are normally intended to be used to share data and/or communicate directly between different tabs/windows running on the same domain in a normal browser. However, in xsplit, each HTML-based plugin runs in its own context as well, just like multiple tabs in your browser, so they can be used here as well.
These APIs only allow communication with the same origin, which is the combination of protocol and domain that the script runs from. For plugins that are local files, rather than web-hosted files, the origin seems to always be "file://", so all local files can communicate with each other.
As for the APIs, there's:
- Storage, which allows sharing persistent named variables between plugins, and can trigger events when variables change (but not when they are set to the same value as before). Normally, these variables are persistent between browser sessions, I haven't tested whether this is also the case within xsplit (and if so, if the values are stored globally or inside the bpres file).
- Broadcast Channel, which allows directly sending messages over one ore more named channels, which can be processed by anyone who is listening at that moment.
I believe that both APIs allow sharing complex datastructure (i.e. not just strings, but also arrays and objects. Maybe even objects with methods and/or functions, haven't tried that).
I haven't looked at how the Macros plugin uses the storage API, though. @nelson-temporal, is that something that can be inspected somewhere? I was under the impression that the Macros plugin does not have its source available anywhere and the installed plugin cannot be unpacked or inspected, or is this not the case?
from xjs.
Hi, this is a video where and how you could get the scripts inside triggers and actions of Macros
https://321.show/rARfTWOdndn.
Glad to be of assistance 👍
from xjs.
Ah, never realized that you could copy existing scripts (and had already forgotten that you could custom scripts). Thanks for the video, maybe macros can be useful in our setup after all. Yet another tool in our toolbox :-)
from xjs.
Related Issues (20)
- Issues with case sensitive matching HOT 1
- Allow `duplicate` item calls to return UIDs of newly added sources
- Expose method to refresh source on show and on scene enter
- Fix documentation
- OnAsyncCallback should handle more than two parameters
- Typescript type definitions HOT 1
- Ability to copy presets
- Provide event callbacks for presets
- How to get source id for item HOT 5
- Set 'play on source show' on media items HOT 1
- Bug ActionAfterPlayback; wrong constants HOT 1
- Bug: isVideo returns false on looping videos
- getPlaybackDuration only works for active scene HOT 1
- Race condition for isVisible (and possibly more checks) HOT 1
- from php script i want to change dynamically source media HOT 3
- Apply new audio changes to XJS HOT 2
- Xsplit Broadcaster extension store
- Stream and recording start/stop event notification HOT 4
- Unable to get name of Scenes HOT 5
- Which kind of format must be? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xjs.