Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"item-created" event for new linked items #245

Closed
paul-lrr opened this issue Jun 26, 2019 · 3 comments
Closed

"item-created" event for new linked items #245

paul-lrr opened this issue Jun 26, 2019 · 3 comments

Comments

@paul-lrr
Copy link

Is there anyway to detect when a new item has been added that is a link to an existing source? The item-destroyed event fires when a linked item is deleted but I don't see event for a new linked item being created. Not even the item-changed event fires when a new link is added.

@mikeybanez
Copy link
Collaborator

Hi @paul-lrr . We can see what we can do here and coordinate with XSplit's core team.

Just curious, what is your use case here? It might help determine the data we can return.

@paul-lrr
Copy link
Author

paul-lrr commented Jul 1, 2019

I'm in the process of updating an system that I have been using for various dynamic overlays (scoreboards, captions, graphics, etc). I want to have a central server that keeps a list of which scene(s) a particular source is being used on. I have sources register with the server when they first load, but if I copy and paste a source onto a different scene as a linked item, the new item doesn't load again, so there is no trigger to register that the source is now on two scenes.

The item-destroyed event handles the opposite situation, so I can listen to that event and update the server when a linked item is removed, but I'm not sure how to handle adding linked items.

@nelson-temporal
Copy link
Collaborator

nelson-temporal commented Jul 4, 2019

Hi paul-lrr,

We are actually planning first to create an event for all 'item-created', then we can just extend it up to 'item-link-created'. For now maybe you could use this simple code to get you started on the functionality you want:

import { ready, Scene, exec } from 'xjs-framework';

ready().then(() => {
  let previousAppOnItemAdded = window.AppOnItemAdded;
  window.AppOnItemAdded = (...args) => {
    previousAppOnItemAdded(args);
    let itemId = args[1];
    Scene.searchItemsById(itemId)
      .then(item => {
        if (item) {
          return item.getSource();
        } else {
          throw new Error('No such item');
        }
      })
      .then(source => {
        return source.getItemList();
      })
      .then(itemList => {
        if (itemList.length > 1) {
          console.log('Item Link Added', itemId);
        } else {
          console.log('New Item Added', itemId);
        }
      })
      .catch(err => {
        console.log(err);
      });
  };
  exec('AppSubscribeEvents');
});

Will just close this ticket for now and create a new one to define the task for this.
Please contact us anytime if you have other concerns.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants