Accessing the Syrinscape API with javascript

I hit a small milestone today. I managed to create a module that reads in the csv and outputs the values to the console.
Not much but baby steps :smiley:

4 Likes

Im super interested in this and your work here.

2 Likes

I was a bit busy the last few days, so I didn’t make much progress. I will have some time off soon though and I plan to use that to continue on the module.

Just keep in mind that this is only a remote. It won’t be able to pipe audio into fvtt directly. That would need a way to add your own player and AFAIK this isn’t planned yet.

1 Like

Small Update:

I got the Parsing off the CSV down, now I need to create the control menus from that data:

  • Using Categories as filters for Soundsets
  • Using the Soundset as Filter for Moods
  • Generating the Links for each Mood
  • Generating a Stop Button (I think I need to use the Silence Soundset for that)
  • Building a nice Menu around all that.

I would also love to find a way, so i can add the Soundsets to Journal Entries and the like in order to start them Quickly.

I shall keep posting updates here.

3 Likes

Thanks for the update @chrome it’s looking really promising :slight_smile:

1 Like

Hello, I’m a Senior Software Engineer. I’m interested I’m helping. I build APIs.

2 Likes

Heya,

Grab us at support at syrinscape dot com and we’ll set you up with the info you need. :slight_smile:

1 Like

Any updates on this? I am eager to try out whatever anyone might have in the works.

Unfortunately I still lack the skill to work with the API as it is right now. I placed my findings in the hands of some other Foundry Devs - hopefully they will be able to pick up th torch.

A few others have picked up the torch and eadorin (patreon “Foundry Workshop”) has a basic mod working (still in alpha), but unfortunately there is no current support for turning Foundry into a minion that broadcasts the sound output by the DM’s Syrinscape Online Player. One can make an interface / GUI in Foundry that allows one to duplicate the functionality of the Master Interface (so you don’t have to switch tabs to change sounds, though you do have to manage an additional window within Foundry). Your players, though, still have to have an Online Player downloaded and connected to your Syrinscape instance, and that Control Panel / Online Player manages things like syncronicity and runs in addition to Foundry.

It’s disappointing to be sure, given the issues a lot of us have with our players struggling around the Online Player / connecting to the DM / a-sync issues / dropped-sounds, but that is where things stand at present.

Hi,

I’ve been working on a custom remote much like the OP, and run into the same CORS issues. I am not a javascript developer, so I’m on a bit of a learning curve - apologies if I ask a stupid question!

It seems (from the little I understand!) that any XHR request from javascript will not be able to return a response - is that right?

Is it possible to consider relaxing the CORS policy, at least for some request URLs? I’m hoping that maybe @sonofconan will be able to give some pointers, if it’s not a bother!

Thanks,
Tom

@yamahito that’s correct. I’ll reply here where we have made the necessary changes on our end to relax CORS requirements. But I can’t say when that might be.

In the meantime, you would need to implement your own local proxy. For example a Python web server that handles your requests and then makes its own request to our server directly without CORS restrictions, or the Node.js proxy linked to earlier in this thread:

1 Like

Thanks for the quick reply!

I’ll have a think about the node.js proxy, but as it may require more hosting, I may just try to be patient :wink:

1 Like

I totally caved and got cors-anywhere working… #SorryNotSorry

2 Likes

I’m trying to get this to work as well, I was able to comment most of the macro the OP posted and it does work…

If I make a Macro in Foundry VTT to play on casting the Bless spell for instance
fetch('https://www.syrinscape.com/online/frontend-api/elements/415635/play/?auth_token=SecretToken', { mode: 'no-cors'})

It plays, but at max volume. Is there a way through the link to specify to play at like 50%? I have the One Shot volume at 100% due to needing the voices to be heard, but if we cast a spell it is very loud.

Thanks

Hi,

My control panel has been working for weeks - until tonight’s game.

I’m now getting 401 responses from syrinscape via the cors-anywhere proxy. Is there an updated way of accessing the URIs?

@yamahito I just tested your control panel, and it seems to be working for me. We have not changed anything that should be impacting your ability to make the same API requests. Is it still not working for you? If so, could you provide any further detail on specific requests that are failing and the body of the 401 response?

Thanks for that; it turns out by the time you would have checked, I was over halfway through fixing.

Turns out the problem was with those API links where I wasn’t processing a response; they were originally made using a GET form, although it was on my list of things to do to change them into XHRs. So that’s what I did, and it’s now working much better than it ever was.

I also had to add timestamps to the state requests, since the browser seemed to be caching those - but that’s by the by.

Odd, though, that the form submits were working for so long and then stopped between last week and this.

It is unclear to me if this is a going concern, but I would like to say that we have added cross origin CORS support to our API, so the proxy should no longer be required, and hopefully this makes it less troublesome to create and maintain these cool projects!

2 Likes

I’m still using the tool, not had much time recently to update it, so it’s still using the old CORS workaround, but no great shakes.

2 Likes